LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert element into array

Im a student trying to do some calculations on ECG-data that i collect in LabVIEW..

I want to store approx 200 sampels from my ECG in and array and then calculate the pulse per minute from that.

But when i try to store the sampels in an array i only gets like 1 sampel every 200 iteration in my loop..

It looks like i get a new array into "replace array subset" every program loop.. Im using iteration from 1-200 as index point where i want to store the sampels in the array

My question is how to store 200 sampels in 1 array so that i can calculate from that..

Attaching a screenshot from the program


/Thanks in advance

0 Kudos
Message 1 of 10
(4,108 Views)
The code you proveded a picture of is adding a single point to a constant array.  The array will never have more than one data point.

You need to put the array in a shift register and add to it every time you get a new value.....

Like this


In addition, the function "Replace array subset" is far more efficient than "Add to array".  If you add to the array 200 times, your end array will be 200 units larger than the starting array.  Using replace array, it stays the same size and is far more efficient when it comes to memory usage.

Shane.

Message Edited by shoneill on 08-31-2006 11:54 AM

Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 2 of 10
(4,101 Views)
Ok i see what you mean.. but when I try your suggestion the program stops at the for-loop until the array is filled with the same value! at all the 200 indexes..

So instead of getting just 1 value in the array i now end up with the same value in the whole array..

It should just iterate +1 and then wait for another sampel.. Smiley Sad
0 Kudos
Message 3 of 10
(4,090 Views)

Use a while loop with either an event or case structure to add each Element at selected Index.

This should do, Look at pic

0 Kudos
Message 4 of 10
(4,083 Views)
OK, what I forgot to mention is that the control in the loop should be replaced by your code returning the value.

Then, each loop iteration, a new value is recorded and placed at the right position in the array.

If you can only pass a single value, then you need to keep track of the index somewhere and simply input this into the "replace array subset" function when you want to store in the array.

Shane
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 5 of 10
(4,071 Views)
dammit .. i really dont get this thing to work.. Smiley Sad

I dont get why the For-loop executes 200 times before the next sampel-value calculates..

And for the "Replace.png" exampel.. when i try that i only get one sampel in the array again.. it makes a new array each loop..

Looks like im doing some fairly simple mistake on this problem.. Smiley Indifferent
0 Kudos
Message 6 of 10
(4,050 Views)
Post your code and someone will probably fix it.

I see other mistakes in your code (Using the "Equals" on two floating point numbers for a comparison is just asking for trouble......) so maybe some of these may be the reason behind your failure.

I won't be able personally to look at your code as I've only got LV 6.1.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 7 of 10
(4,038 Views)
It sounds like you only want to add the value to the array when the data value changes.

An event structure can do this for you by only adding the data, when the data value changes... assumed this is the functionality you want.

Message Edited by MJBrehm on 08-31-2006 10:18 AM

0 Kudos
Message 8 of 10
(4,036 Views)


@Sulos wrote:

I dont get why the For-loop executes 200 times before the next sampel-value calculates..




Is the code that obtains the data outside the For Loop?  If you have a sub-vi which does the data acquisition, move it inside the loop. ie replace the "Data Source"  from the picture.

RayR

0 Kudos
Message 9 of 10
(4,024 Views)
Thanks for all the inputs and tips! the problem is now solved 🙂
0 Kudos
Message 10 of 10
(3,959 Views)