LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pointer Manipulation: Wrap Around/Rollover/Rotation of LabVIEW Arrays and Waveforms???

I know we can't use pointers in LabVIEW, but I was wondering if there's any way we can do wrap-around [or "rollover," or "rotation"] of Array [or Waveform] values without having to make copies of the Array [or Waveform]?

For instance, suppose I'm reading one second's worth of data into a five second buffer. After the first five seconds, I've got

1st (1/5)th: 1st second's worth of data
2nd (1/5)th: 2nd second's worth of data
3rd (1/5)th: 3rd second's worth of data
4th (1/5)th: 4th second's worth of data
5th (1/5)th: 5th second's worth of data

Now I read the sixth second's worth of data, and overwrite the [original] first second, so that I have

1st (1/5)th: 6th second's worth of data
2nd (1/5)th: 2nd second's worth of data
3rd (1/5)th: 3rd second's worth of data
4th (1/5)th: 4th second's worth of data
5th (1/5)th: 5th second's worth of data

and in C, or C++, I'd just move the pointer up to the second (1/5)th of data, and start from there.

The LabVIEW Complex FFT is another place where this would be really useful. The Help File for the Complex FFT is in

Help | VI and Function Reference | Analyze VIs | Signal Processing VIs | Frequency Domain VIs | Complex FFT.

If you read the Help File, you see that LabVIEW returns an FFT with values in the range

[0, 2n - 1)

rather than the standard

[-n, n - 1)

i.e. LabVIEW takes the negative frequencies and tacks them on at the end, after the positive frequencies.

I'd like to be able to view my FFTs with the negative frequencies where they're supposed to be [i.e to the left of zero], and this would be SO easy if I could just move the underlying data pointer of the Waveform forward to the halfway point.

But, of course, in LabVIEW, I don't have pointers, so I was wondering: Are there any built-in VIs for Array [or Waveform] manipulation that will perform this sort of wrap-around [or "rollover," or "rotation"] of the data? If so, I couldn't find them. Ideally, such a VI would have two inputs: {old Array, new starting point}, and one output: {new Array}. Similarly with Waveforms, only you'd need to manipulate t0 as well.

Or do I have to copy the entire data set to a new Array [or Waveform] each time I reach the end of the buffer?

Thanks!
0 Kudos
Message 1 of 3
(2,672 Views)
> Ideally, such a VI would have two inputs: {old Array, new starting point}, and one output: {new Array}.

Have a look at "rotate 1D array" in the array palette (second row, fourth column).

(Sorry, I dont use waveform data).
0 Kudos
Message 2 of 3
(2,672 Views)
Thanks.

It's late, and I'm getting tired, but maybe tomorrow, or this weekend, I'll try to benchmark that VI and see whether they're doing anything more than an array copy, i.e. whether they're doing something sneaky like keeping track of two pointers within a structure so as to avoid the expense of a memory copy.

Also, I just searched the VI database, and got hits on "Rotate 1D Array" and "Rotate String," but I didn't get any hits on rotating an entire waveform, so I guess I still have to break the waveform down into its constituent parts, rotate the 1D array, re-calculate t0, and then re-assemble the parts.

Man, it sure would be nice if that came pre-packaged.
0 Kudos
Message 3 of 3
(2,672 Views)