LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I insert multiple values in various positions of an array in a wile/for loop?

I'm trying to create an interpolation function, so I can insert a bunch of values into various positions of an array. But when I try to insert values in  ( constant  *  [ i ] ) position of the array, it only inserts the first one... what can i do??

thaks
0 Kudos
Message 1 of 11
(6,742 Views)

First, you have to define a blank array( zero array if it is a numeric array) using 'initialise array' function ( found in functions palette>>arrays)

Now, you can insert/replace elements in this array, using 'insert into array' or 'replace aray subset' functions from Array functions.

this can be done for arrays of all dimensions

hope this helps.

regards

Dev

0 Kudos
Message 2 of 11
(6,735 Views)
I have an original array of values fom an ECG signal, and I want to insert a value in position x, 2x, 3x, 4x..., because im going to make a coreation coeficient, and I need to compare 2 diferent arrays with diferent sizes. So i need to interpolate the smolest array!! And when I try to insert various values in the array (eg: my array has 200 point and I need one whith 220 points, so i need to insert 20 points. one in idex 5, other in idex 10, other in index 15...) I can only insert the first one, even in an for cicle...

heres the sample:



0 Kudos
Message 3 of 11
(6,728 Views)
Hello hybrid,

two errors:
- First you have to use a shift register in the for loop to hold your array. Otherwise it will take always the original data in the next iteration! Think of dataflow!
- Second you better start inserting at the end of your array. Otherwise the indexing will be wrong! (After inserting at index 0 the old element at index 0 becomes index 1 and so on...)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(6,719 Views)
thanks... i've done it! Smiley Very Happy
0 Kudos
Message 5 of 11
(6,713 Views)
Hi all,

I'm programming a mathematical simulation wtih Labview. In order to program the times of different stimulations (a binary variable, X = {0, 1}), I must insert one of these values at different position in an array, say 1, 3, 6, 8, 14, etc.. Unfortunately, I didn't fihd a solution for this task. Can you help me?
Thank you in advance

@devchander wrote:

Firstt, you have to define a blank array( zero array if it is a numeric array) using 'initialise array' function ( found in functions palette>>arrays)

Now, you can insert/replace elements in this array, using 'insert into array' or 'replace aray subset' functions from Array functions.

this can be done for arrays of all dimensions

hope this helps.

regards

Dev






@devchander wrote:

First, you have to define a blank array( zero array if it is a numeric array) using 'initialise array' function ( found in functions palette>>arrays)

Now, you can insert/replace elements in this array, using 'insert into array' or 'replace aray subset' functions from Array functions.

this can be done for arrays of all dimensions

hope this helps.

regards

Dev






@devchander wrote:

First, you have to define a blank array( zero array if it is a numeric array) using 'initialise array' function ( found in functions palette>>arrays)

Now, you can insert/replace elements in this array, using 'insert into array' or 'replace aray subset' functions from Array functions.

this can be done for arrays of all dimensions

hope this helps.

regards

Dev




0 Kudos
Message 6 of 11
(6,689 Views)
This VI should help u.
 
read the 'note' written on the block diagram/front panel
0 Kudos
Message 7 of 11
(6,680 Views)

Thank you

But  I did'nt want to insert this element manually. In fact, every elements to be inserted in this array(a)  are in another array (b) yet. And there are a lot of elements in there(b).
Do you know a way of inserting them programmatically ?


0 Kudos
Message 8 of 11
(6,673 Views)
Hello behavior,

so you have a list of elements in a first array and you want to insert them in a second array.
So you just have to use 'index array' on the first array and 'insert into array' with the second array...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 11
(6,668 Views)

OK

I don't know why I didn't think about that. It should work

Thank you
0 Kudos
Message 10 of 11
(6,665 Views)