LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview beginner

Solved!
Go to solution

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 

0 Kudos
Message 1 of 17
(3,878 Views)

Hi bagarman,

see the attached image.

 

Mike

0 Kudos
Message 2 of 17
(3,865 Views)

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

0 Kudos
Message 3 of 17
(3,863 Views)

Use a shift register. Like this.

 

shi.JPG

0 Kudos
Message 4 of 17
(3,859 Views)

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:

 

CreateIncrementingArray.png

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 17
(3,812 Views)

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:

 

CreateIncrementingArray.png

 


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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 17
(3,802 Views)

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.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 17
(3,771 Views)

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

0 Kudos
Message 8 of 17
(3,760 Views)

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.

 

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 9 of 17
(3,750 Views)

Hi tbob,

if the number is unsigned and the end is smaller than the start, then the subtraction results in a big number.

 

Mike

Message Edited by MikeS81 on 03-31-2010 09:30 PM
0 Kudos
Message 10 of 17
(3,745 Views)