LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add row to 2-D array on each loop interation

I have a loop that produces a 880 element long vector (1-D array) each loop interation.  I want to build a matrix where each row is the data for the various loops.  so if the loop runs 50 times I will have an 880x50 matrix where the result of each loop is represented by one column.  I am going to use this to take a time average of the data and produce a single 880 element array.
 
I can't figure out how to get the array tools to do this for me.  I have tried insert into array and several others.
 
Thanks
Message 1 of 10
(5,611 Views)

I think what you want to do can be accomplished with shift registers and a Build Array function:

Hope this helps,
-D

Message Edited by Darren on 03-27-200603:17 PM

Message 2 of 10
(5,604 Views)
In the attached VI, the inner FOR loop simulates your loop that runs 850 times.
In my example it only runs 10x.
 
Each iteration of the outer FOR loops adds a row to the 2-D array.
 
 
 
Download All
0 Kudos
Message 3 of 10
(5,592 Views)
Instead of building huge 2D arrays in a loop, it might be much more memory efficient to to the averaging in realtime.
 
Just initialize a shift register with a size 880 1D array and add your new data at each interation, then divide by N+1 to display the average. (Or divide by N+1 after the loop is done if the loop runs fast and you don't want to monitor the data progress).
 

Message Edited by altenbach on 03-27-200602:01 PM

Download All
Message 4 of 10
(5,586 Views)

Good call, I just skimmed the original post and didn't realize he was going to be averaging each column at the end.  Makes more sense to do the averaging in the loop so he doesn't keep building a huge array.

-D

0 Kudos
Message 5 of 10
(5,572 Views)
i would like to know how to add row and insert elements on each row of array automatically on each loop iteration. i want to create a program where the user will click on the boolean buttons (on off switch) and the program will store the data and build an array automatically with the selected buttons. if the user does not click on the button it wont build the array with it. please advice on how i should program it.
Message 6 of 10
(5,237 Views)

Once again.  Start a new thread!

 

Your button layout doesn't make much sense.  You have a single "Male" button.  If that is not pressed, would the opposite be "Female".  But if that's the case, why are "Short" and "Tall" on their own buttons.

 

What have you done so far?  What is your specific programming question?  We can't help you write your program.

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
0 Kudos
Message 7 of 10
(5,233 Views)
my button layout dont have to make any sense cause im just giving an easy example on how to create what i want. this is just a small piece of my big puzzle. if i cant make this small program work im unable to implement it in my bigger program. the "Male" is just an example. you dont have to care about it. i just put the word "male" to represent a button. its just an on off button. its just a word. if its not pressed it wont be "female" it will just produce the signal "off" and it wont create the array.  i figured that you would ask me about the short and tall button hahahah...well its just a button.. dont care about the meaning of it. i just give an example.  im really sorry about the confusion and mix up. So far i have just created the array but my result is not what i want. the result just gives me an array with all the same words in every row.. i want to be able to automatically generated the array based on the button i have click thats all. but it wont add the row to my 2D array. i just need an example for me to fix my problem thats all. so that i can implement and write my own program. but the creation of the array on each loop iteration is giving me a headache
Message Edited by Trig on 12-18-2008 09:34 PM
0 Kudos
Message 8 of 10
(5,230 Views)

Like I said, start a new thread rather than hijacking other people's threads.

 

I don't care whether the button says male or something else.  Having a button that says short and another one says tall, looks like they are somehow related and meaningful, but you say it isn't.  All you have given is a front panel while asking for help, and you say that is doesn't have to make sense but yet it is an "easy" example of what you want to do.

 

Please post your VI so we can see what it is you have done so far, then it might be possible to figure out what it is you are really trying to do.  The threads you have posted into have already given examples of how to work with arrays in different manners. 

0 Kudos
Message 9 of 10
(5,222 Views)

@Trig: Post #2 sounds like it would solve your problem.

 

Your different buttons can be saved by e.g. using Replace subset to chance the different columns, or build all buttons as a cluster and simply add that.

 

/Y

Message Edited by Yamaeda on 12-19-2008 03:20 AM
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 10
(5,204 Views)