LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to shift an array

I have an array. I wish to shift it by 10 terms.
i.e the A[0] will be A[10]. I will pad the first 10 terms to zero.
is there a simple way of shifting the array?
0 Kudos
Message 1 of 5
(12,604 Views)
If the resultant array is to have the same number of elements as the input array, the attached code should do the job. If the output array is larger than the input array, simply concatenate an array containing 10 elements of zero to the beginning of the input array.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 5
(12,604 Views)
Have a look at the array functions, there you find the "rotate array"
functions.

Niko
Message 3 of 5
(12,604 Views)
Let me tell you my application.
I am continously acquiring data from 2 channels( interchannel delay is negligible ).
I want to phase shift one waveform by 10 terms. So after processing data
channel 1 : 2 4 7 9 4 6 8 9 0 2 3 4 5 6 7 8 ......
channel 2 : 0 0 0 0 0 0 0 0 0 0 2 4 7 9 4 6 8 9 0 2...

I guess as u sugguested, to concatenate an array of zeros..
any more suggestions?,
thanks!
0 Kudos
Message 4 of 5
(12,604 Views)
Just that, in general, concatenating arrays is less efficient due to the memory management tasks that LV has to do in the background. If at all possible it is usually faster and more efficient to allocate the memory for an array ahead of time and then populate the values as you acquire them.

But there are exceptions, so what ever you do be sure to test a couple different approaches to verify the efficiency of your application.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 5
(12,604 Views)