LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array

I'm taking in a signal from a laser detector only when it is at 5v. I want to run a scan several times, during each scan i want to create an array of the data and at the start of the new scan i want it to add to the corresponding elements of the old scan. i would like to keep repeating this unitl a certain number of scans. i've tried using a while loop and shift registers to build an array, but i don't know how to add two arrays especially if it's going to be rewritten on the next scan. any help would be appreciated.

i've attached the code. thanks.

0 Kudos
Message 1 of 12
(3,957 Views)

A lot of your code did no make a lot of sense to me, probably because I don't have DAQmx installed. 😉

 

Anyway, you probably should make sure that your globally initialized feedback node contains something reasonable, else adding new dynamic data will result in an empty output. Maybe something like the following?

 

Message Edited by altenbach on 12-19-2008 09:07 AM
Message 2 of 12
(3,934 Views)

This VI may give you some help on your task, its not a solution for your work only an aid to get some ideas on your implementation. You have to do the work to customize it the way you want. The array is appended at the end of the vi run (not sure if you meant add index or append arrays...) this you can change as you see fit.

 

I have not looked at your code, furthermore if its LV 8.6, I don't have that version to open your vi anyhow.

 

regards,

Message 3 of 12
(3,915 Views)

RichJoh

 

Your code is really helpful, I need to add each corresponding index of one array to another, I'm not sure how to do that. I've tried using a feedback node of some sort, everything I've tried just appends, at the end I'd like to have an array that is composed of all the summations of each respective index. Therefore, all the arrays will be the same size. Thanks again for your help.

0 Kudos
Message 4 of 12
(3,864 Views)

Hi Clapas,

 

I am not sure that I know mean by "add each corresponding index of one array to another".  Could you explain this to me?

Justin Parker
National Instruments
Product Support Engineer
Message 5 of 12
(3,764 Views)

If I understand your question correctly, you want to add a specific value in an array, to the new value.

Then place that sum where the old value used to be. Correct? If so: 

 

Just replace the index with whatever you want to index in your array.

And put whatever logic gathers a value in place of 'current iterations value' 

Message Edited by Cory K on 12-29-2008 11:14 AM
Cory K
Message 6 of 12
(3,758 Views)

If you wanted to replace many values in an array, try this little modification to my last program:

 

Message Edited by Cory K on 12-29-2008 11:27 AM
Cory K
Message 7 of 12
(3,753 Views)

ClapasLabViewUser2 wrote:

Your code is really helpful, I need to add each corresponding index of one array to another, I'm not sure how to do that. I've tried using a feedback node of some sort, everything I've tried just appends, at the end I'd like to have an array that is composed of all the summations of each respective index. Therefore, all the arrays will be the same size.


You need to initialize your Shift register (or feedback node) with an array of the correct size, then you just add the new array data with each iteration as follows.

 

 

 

If you get your data one point at a time and you want to see the updated sum after each element (because acquisition is slow), use something like this.

 

 

 

Note that these are just sketches, they need more code to be runnable. 😉

 

(none of the code posted above make a lot of sense:

In Cory's examples the shift register is initialized with an empty array, so it will stay empty forever because you cannot replace an element outside the valid range. The example by richjoh is overyl complicated. To append data to an existing array one would use "built array" and initialze the shift register with the old data. Currently, the shift register in not initialized, so things will go haywire the next time the VI is run.)

Message Edited by altenbach on 12-29-2008 10:23 AM
Download All
Message 8 of 12
(3,746 Views)

Altenbach, what is the name of the function you used in your second example?

I have never seen that before.

I am referring to the one that seems to be an Index, Modify, Replace array function. 

Message Edited by Cory K on 12-29-2008 12:29 PM
Cory K
Message 9 of 12
(3,739 Views)

altenbach wrote: 
In Cory's examples the shift register is initialized with an empty array, so it will stay empty forever because you cannot replace an element outside the valid range. 

I just wired it to an array of 0 because I needed wires to work with  :smileywink:
you could just wire it to where I said 'wire your array here'


 

 

Cory K
Message 10 of 12
(3,733 Views)