07-18-2024 06:26 AM
I would like to built a custom array containing numbers from 0 to 128, I have already done that using a FOR loop and autoindexing. Now I'd like to append eight zero's after every 8 elements, so my new array would look like: 0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,0,8,9,10,11,12,13,14,15,0,0,0,0,0,0,0,0,16,19, .... and so on. How can this be implemented?
I tried using insert into array and build array functions, but I can't seem to figure it out.
Solved! Go to Solution.
07-18-2024 06:49 AM
Not sure how much smaller Altenbach can make it...
07-18-2024 07:14 AM
Not smaller, but I don't use Build Array inside For loop.
07-18-2024 07:14 AM
Thank you !
Additionally, could you recommend some resources (free) to learn logic building for LabVIEW specifically? I have a difficult time trying to make things on LabVIEW which I can easily code in text based languages such as C++/python.
07-18-2024 07:25 AM
Hi Zain,
@ZainAli02 wrote:
could you recommend some resources (free) to learn logic building for LabVIEW specifically? I have a difficult time trying to make things on LabVIEW which I can easily code in text based languages such as C++/python.
The "logic" is always the same!
LabVIEW doesn't need "variables", you use wires instead… (THINK DATAFLOW!)
07-18-2024 08:04 AM
Does your initial array have 128 or 129(!) elements? You said "from 0 to 128", which suggests you have a 128-element array [0, 1, ..., 126, 127] and add on a singleton 128.
I'm going to assume your original Array had 128 elements, so goes from 0 to 127. I would handle this problem in a different way that uses no loops at all, but treats the Array as an "array" and does "array manipulation" to get your solution (that's the "mathematician" hat I'm currently wearing). Here are the steps (verbally -- carrying them out will be a nice "teaching/learning" exercise).
So I wrote down these steps, but before pressing "Post", I decided to try it. Oops, there's a "feature" that I forgot about, but there are work-arounds. [It is simple enough to put some Array Indicators at output points to make sure you are doing what you think you are doing].
So my version of this "teaches" you some useful "Array-manipulation" functions that (if you use arrays much) will come in handy. Enjoy the puzzle.
Bob Schor
07-18-2024 09:07 AM
@ZainAli02 wrote:
Additionally, could you recommend some resources (free) to learn logic building for LabVIEW specifically? I have a difficult time trying to make things on LabVIEW which I can easily code in text based languages such as C++/python.
Just wait until you get to (advanced) threading situations. You'll realize you don't have to worry at all about data integrity (and the related deadlocks\livelocks).
Or nD arrays (although n>2 is a code smell)...
07-18-2024 09:39 AM
Two flat loops tend to scale better than two stacked loops.
(Not sure what to do with the "128" you seem to want, so adjust as needed)
07-22-2024 12:34 AM
The "logic" is always the same!
LabVIEW doesn't need "variables", you use wires instead… (THINK DATAFLOW!)
I am just a few months old into LabVIEW, could you point in any directions that could help me?
07-22-2024 12:36 AM - edited 07-22-2024 12:38 AM
@Bob_Schor wrote:
So my version of this "teaches" you some useful "Array-manipulation" functions that (if you use arrays much) will come in handy. Enjoy the puzzle.
Thank you Sir for this. It'll definitely help me in the longer run and I will surely give this some time to figure it out and implement it. The array is meant to be 128 elements, so from o to 127, that was a mistake on my end. 😅