LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save data to array(delete two previous wrong threads, please )

Sorry ,I have put two same threads in this board by wrong operation, please delete for me.Thanks.
 
Hi, I want to save a series of data to an array in the
following prosedure: The first data come (index of array
= 0), save the data to a(0), then the second data come,
array index +1,  save the data to a(1),...... I have write a
vi, but it doesn't work Smiley Sad
 
0 Kudos
Message 1 of 15
(3,593 Views)
trinigh,

I'm not sure I get your point and only have LabVIEW 7.1, so could you just post an image of your diagram.

If what you want is to build (not save) an array, you should use the "build array" function in a loop, like this...

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 15
(3,590 Views)
Hi, TiTou. Here is the image of my vi. 
0 Kudos
Message 3 of 15
(3,594 Views)
Hi trinight,
here is the image of a VI that does it 'the labview way'  Smiley Wink  :


Try to avoid local variables. There is only very seldom a need for them.


-Franz

Message 4 of 15
(3,585 Views)
Yep, as I was assuming, what you are trying to do is to build an array (or add values in an array) to do this you have different possibilities.
As Franz mentioned, you can use a loop (while or for loop) with indexing, you can also use the "build array" function (like in the VI I posted) with a shit register, the principile is to initiate with a empty array before entering the loop and adding a value at end or at begining only when you want.

Hope my VI is clear enough and helps you, if not, feel free to ask questions 😉

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 5 of 15
(3,577 Views)
Hi, fahlers . I write a vi in the way of your image, but  only the first two elements change with the for loop. I don't know why. If the data source isn't from the for loop, there isn't the "enable indexing" how to the same thing? 
0 Kudos
Message 6 of 15
(3,570 Views)
Hi trinight,

I thought your problem was solved... I might not understand correctly what your are trying to do... could you post your last VI with some documentation in the diagram to explain what you expect your VI to do..

Thanks

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 7 of 15
(3,563 Views)
In a WHILE loop, you can right click on the output tunnel and select 'enable indexing'.
(Likewise it is possible to right click a tunnel of a FOR loop to 'disable indexing'. It is just a different default for the two kinds of loop. )

Be aware that there may be a lot of memory allocation overhead when autoindexing from a WHILE loop: the compiler cannot know beforehand how often the WHILE loop runs and therefore has to allocate additional memory from time to time. In a FOR loop the compiler does know how many array elements there will be.


-Franz
0 Kudos
Message 8 of 15
(3,556 Views)
Hi, TiTou. Thanks first. I was reading your vi, and made some change based on your vi, I wrote my purpose in the image posted. 
0 Kudos
Message 9 of 15
(3,555 Views)

Hi,

This VI should work for You

Run it and let me know if it serves your purpose

Regards

Dev.

 

0 Kudos
Message 10 of 15
(3,548 Views)