LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to do a for loop

Solved!
Go to solution
Well I have a problem I don't know how to solve it.

The idea is simple but I have no idea how to implement it on LabView. Here it goes:

I start with an array a[i]. For i from 1 to 5 i initialize all values with zero. I want to build a for i from 1 to 5 loop that for each iteration replaces the i'th value of a[i] with i.

Maybe I'm missing something but I just don't know how to do it. I would appreciate it if you could give me some tips.

Regards,
0 Kudos
Message 1 of 16
(3,332 Views)

Welcome to LabVIEW.  You may want to spend some time learning about LabVIEW, it will make using it much easier.  A good place to start is the Learning Center at the Developer Zone.  You may also want to take a look at the free online courses offered here.

 

A for loop that is five indices long where each index holds the iteration number of the loop would look like this in LabVIEW:

 

 

 

 

 

 

 

 

 

 

 After re-reading your post I see that you want something slightly different than the solution above, but the example I showed you should be enough to get you going on the solution you are looking for.  Feel free to ask questions as they come up!

 

Message Edited by jmcbee on 04-17-2009 11:37 AM
0 Kudos
Message 2 of 16
(3,326 Views)
Message Edited by Wayne.C on 04-17-2009 01:39 PM
0 Kudos
Message 3 of 16
(3,321 Views)
yeah...i know all this but i need to start with a predifined array then modify it. I don't want to build it.
0 Kudos
Message 4 of 16
(3,316 Views)

You can initialize an array with the "Initialize Array" function, located in the palette at "Programming >> Array >> Initialize Array".

 

Chris M 

0 Kudos
Message 5 of 16
(3,311 Views)

Is this what you are looking for?

 

 

 

 

 

 

 

 

 

Message Edited by jmcbee on 04-17-2009 11:45 AM
0 Kudos
Message 6 of 16
(3,310 Views)

This is what CMal is talking about:

 

 

 

 

 

 

 

 

 

 

Message Edited by jmcbee on 04-17-2009 11:49 AM
0 Kudos
Message 7 of 16
(3,295 Views)
Solution
Accepted by topic author zmuccelmic

Can be done this way.  Not sure why you need to initialize and then replace.  Much easier to just create using autoindexing.

 

Message Edited by Wayne.C on 04-17-2009 01:52 PM
0 Kudos
Message 8 of 16
(3,287 Views)

Wayne.C wrote:

Can be done this way.  Not sure why you need to initialize and then replace.  Much easier to just create using autoindexing.

 

Message Edited by Wayne.C on 04-17-2009 01:52 PM

 Memory Allocation? 🙂

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Message Edited by jmcbee on 04-17-2009 11:59 AM
Message 9 of 16
(3,281 Views)

If one needs to demonstrate how to initialize an array of a given size with a predetermined constant and then demonstrate how to replace values of that array, I suppose my way works.  Assignment?

0 Kudos
Message 10 of 16
(3,275 Views)