LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interpolating 1D array

Hello:

I want to interpolate a 1d array, for which many types of interpolation exist (including the built-in LabVIEW fxs for interpolation).  The catch is that I want the interpolation to produce an array size that is based on a factor I specify.  For example, if I want 2x density, the interpolation will produce an array twice the original size.  Vision has the IMAQ resample routine for 2d array data that essentially does this - the user just specifies a new array dimension (resolution) in each of the X and Y axes.

The built-in Interpolate 1D array.vi fx seems to produce an array that is about 4 times the original size, even with the ntimes input = 2.  I suppose I could just perform a decimation of the correct order after determining the relationship between the ntimes and interpolated array size for different values of ntimes.  Is there a better (more efficient) way to go about doing what I want to do for a 1d array?

Thanks,

Don
0 Kudos
Message 1 of 12
(6,910 Views)
HI,
Please elaborate on what you mean by 2x density.  It sounds like you want to insert elements into the alreeady existing array.  You will probably have to develop the code to accomplish this because there aren't any existing functions that I know of to speed up the process.  Try to give me some more details about what you are trying to accomplish.
Eric A.
National Instruments
Distributed I/O Product Support Engineer
0 Kudos
Message 2 of 12
(6,867 Views)
For example, if 100 points in original array, 2x density would mean the array size would now be 200 points.  Again, consider the IMAQ resample function where you specify new resolutions directly as input to the fx.
 
Sincerely,
 
Don
0 Kudos
Message 3 of 12
(6,849 Views)

Don, you should give a glance to the resample waveform function (in the signal processing subpalette. Seems that it does what you are looking for !

Message Edité par chilly charly le 10-23-2007 05:05 PM

Chilly Charly    (aka CC)
Download All
Message 4 of 12
(6,830 Views)

Dear Chilly,

 

thanks for this solution it worked quite well for me although I have a small problem with it for which you might have a solution or an idea.

I posted my problem in a similar topic/thread:

http://forums.ni.com/t5/LabVIEW/How-to-resample-unequally-spaced-data-in-Array-form/m-p/1329786/high...

 

So I tried several methods to sort out my resample/interpolation problem and your way seems to be the best, but it's adding a few 0s at the end of my resampled array. I wonder if you have an idea why this would happen, because everything else (size of the array and the rest of the interpolated values seem to be good).

 

Thanks,

Attila

0 Kudos
Message 5 of 12
(6,450 Views)

I'd rather post a screenshot too, to make things easier to understand:

 

resample_issue.PNG

 

 

So as you can see I'm trying to match the template to the final array size (236 to 600(left) and 625(right)).

Any idea or suggestion is welcome!

 

 

Thnaks,

Atttila

0 Kudos
Message 6 of 12
(6,444 Views)

Hello Attika,

 

With the Resample Waveforms (single shot).vi you have the option to 'open interval? (F)'  This option chooses the interval of the input to sample.  If you set this value to true, the trailing zeros will be removed.  If the value is set to false, these trailing zeros appear.

 

The Align and Resample Express VI has the same options and you can play around with these settings to determine which work for your application.  You can read more about them here: http://digital.ni.com/public.nsf/allkb/3DADE9F3962FF89E86256D25005EBD48?OpenDocument.

 

Best of luck!

National Instruments
Senior Systems Engineer
0 Kudos
Message 7 of 12
(6,412 Views)

My favorite 1d interpolation routine is now the 'Interpolate 1d Fourier.vi'.

 

It allows choice of interpolation factor or interpolation size.  It works great.

 

Don

Message 8 of 12
(6,398 Views)

Dear Don,

 

thank you for the reply, I've been trying different options to tackle this problem, but the situation seems to be qutie complex.

To summarize my problem I describe it in a different way now:

 

the orginal task is to compare to 'graphical signals', two spirals; one is a template, a perfect spiral genereted previously by a different program, the other is a hand-drwan figure (these are different in size: the template is a fixed-size array, but the hand-drawn array is completely random sized). To make matter worse, the problem is that this hand-drawn array of X,Y points is that they are not sampled equally in time. I have a timestamp for each, but they are not equally spaced. My goal is to somehow make it possible to compare these two signals first coordinate-wise, then in a polar system and eventuially in the frequency domain.

My approach right now is to somehow interpolate the timestamp vector first, and then resample/interpolate the X and Y vectors of the hand-drawn figure to the same size as the previously interpolated time vector. this way I could get an equally spaced time/X/Y set of vectors of a certain length. Then I should interpolate the template signal to the size of the previously interpolated set of vectors of the hand-drawn figure so I could compare the two signal at the same positions in time and frequency.

 

Unfortuanetly I've still haven't solved the first part, where I want to create the equally spaced time/X/Y vectors, so if anyone has any suggestions please share it here!

 

Thank you again for your continuous help!

 

Attila

 

 

0 Kudos
Message 9 of 12
(6,367 Views)

Hi Attila,

 

You should be able to interpolate the timestamp using the Interpolate 1D VI.  If you set the X input to the timestamp vector (converted to a number - I used seconds in my testing) and the Y input as the index vector for the timestamp vector, i.e. [0, 1, 2, ..., length(X)-1, length(X)].  You then can set the xi input to your desired equally-spaced timestamp vector.  This will then output yi, your updated index vector.  Using that xi though, you are able to interpolate your X and Y vectors accordingly.

 

Regards,

 

Lynn

National Instruments
Senior Systems Engineer
Message 10 of 12
(6,321 Views)