03-31-2010 01:40 AM
Good morning,
I am Labviewanfänger
unfortunately, I ask for your help, and hope that you will help me.
I need to create an array
using For loop, the elements of the array must be monotonically
increasing so by 1, it must match the array size of the loop number of loop
current.
I hope that I have
described my problem correctly.
So an example.
-3 -2 -1 0 1 2 3 4 5
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1
0 1
2 3 4 5 6
5 6 7 8 9 10 11 12
Solved! Go to Solution.
03-31-2010 02:00 AM
Hi bagarman,
see the attached image.
Mike
03-31-2010 02:01 AM
Hey.
Are you wanting to only read the array after the loop has executed or while the loop is executing? If only after, then are you meaning like this vi
Jevon
03-31-2010 02:02 AM
Use a shift register. Like this.
03-31-2010 11:13 AM
There are so many ways to do it. But in the original question's vi, it seems like the user wants to specify a starting and ending number (looks like German labels, I don't know German, so I'm guessing). Here is a way to make it so:
03-31-2010 11:37 AM
tbob wrote:There are so many ways to do it. But in the original question's vi, it seems like the user wants to specify a starting and ending number (looks like German labels, I don't know German, so I'm guessing). Here is a way to make it so:
Since you are using signed numbers don't forget to validate your data to ensure that the ending number is greater than your starting number. Otherwise your loop will run LOTS of iterations. Tbob's example doesn't include the data validation.
03-31-2010 01:47 PM
Mark Yedinak wrote:Since you are using signed numbers don't forget to validate your data to ensure that the ending number is greater than your starting number. Otherwise your loop will run LOTS of iterations. Tbob's example doesn't include the data validation.
Actually, if the starting number is greater than the ending number, the subtraction provides a negative number to the N terminal of the For Loop, and the loop does not execute at all. Try wiring a -10 to N. The loop doesn't execute.
Also, when I write example, I keep it simple and to the point, and don't add bells and whistles to do input checking and such. I leave that up to the programmer unless he specifically asks for such input checks.
03-31-2010 02:04 PM
Mark Yedinak wrote:
Since you are using signed numbers don't forget to validate your data ...
Hi Mark,
it should only be a problem if these where unsigned numbers. 😉
Mike
03-31-2010 02:21 PM
MikeS81 wrote:
Mark Yedinak wrote:Since you are using signed numbers don't forget to validate your data ...
Hi Mark,
it should only be a problem if these where unsigned numbers. 😉
Mike
It doesn't matter if the numbers are signed or unsigned. The loop will not execute if the input to N is 0 or a negative number. In the case where the inputs are unsigned, the output of the subtraction is also unsigned and the result is 0 if the start is greater than the end. In any case, the loop doesn't run. The output array is empty.
03-31-2010 02:29 PM - edited 03-31-2010 02:30 PM
Hi tbob,
if the number is unsigned and the end is smaller than the start, then the subtraction results in a big number.
Mike