LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interpolation of Measurement with Unevenly spaced time series

Solved!
Go to solution

Hello Everyone,

 

I am trying to add two measurements together. The problem is that both measurements possess different time stamps and they are also of different sizes. One signal is an analog input with a sampling frequency of around 10 kHz. The other signal comes from a serial communication with unevenly spaced time stamps. I have around 100K samples from the analog input and only around 1K from the serial measurement. Every sample has a timestamp. How can I add both signals in correlation with their corresponding timestamps? In other words, I want to add both arrays when their timestamp is the same (or the closest timestamp available).

 

If I simply add both arrays. Only the first 1K values are added, since thats the array size of the smaller array.

 

I have tried interpolating the smaller serial array to reach the number of samples of the analog signal. I have performed a simple 1D-array interpolation, which you can see below.

 

Maxmai98_2-1681828722489.png

 

I then plotted the new array with the timestamp of the analog input signal. This approach however, completely ignores the original timestamps of the serial signal. Below you can find a graph plotting the interpolated signal in comparisson with the original. The red plot serves as a time referece, to see how the signal should look like (Please ignore the difference in Y-Values). As you can see, the interpolated signal is not following the reference time. This is caused by the use of the timestamp of the analog input, in other words it is plotting the samples in an even 100 kHz sample frequency.

 

Maxmai98_0-1681828523489.png

 

I thought about taking the analytical approach and somehow estimating a function for the serial signal f(t,y). Then I could simply input the time value to find the corresponding sample, which I can then use to add to the analog signal. However, I do not know how to properly do this.

 

Any suggestion would be highly appreciated.

 

Thanks in advance

Max

 

0 Kudos
Message 1 of 5
(996 Views)

Please attach your Vi and data. We cannot work with pictures. Thanks!

 

For each dataset, you know N, x0 and dx, so all you need to do is create an x ramp that covers all, then interpolate each of the two arrays (or use the x values of the array that covers all to interpolate the other array). 

0 Kudos
Message 2 of 5
(979 Views)

Hello,

 

yes sorry. I forgot to attach the Vi. Attached you will find another test with fewer samples.

 

I am trying to compare both signals. For example, I would like to subtract one plot from the other to find out the error between the two. The main problem is that the array size differs between the signals. Furthermore, one signal is a waveform with a fixed sampling rate and the other is a combination of double values and their corresponding timestamps. How can I compare the two?

 

I tried performing a basic interpolation based on the number of samples needed, but then I cannot plot it, because the array of timestamps does not have the same amount of values as the interpolated array.

 

Thanks in advance

Max

0 Kudos
Message 3 of 5
(945 Views)
Solution
Accepted by Maxmai98

Do your graph data as array of points (xy clusters) instead of cluster of xy arrays, and interpolate 1D array  will understand it.

 

See if this can give you some ideas.

 

altenbach_0-1681939721886.png

 

Message 4 of 5
(925 Views)

Hi again,

 

that is exactly what I was trying to achieve.

 

I really appreciate it!

0 Kudos
Message 5 of 5
(892 Views)