How to identify corners of data plotted to estimate data between corners

1 view (last 30 days)
I have oil pressure data as shown in the plot attached. The data is 10 Hz (speed data points are collected) but the signal is only updated at 1Hz. This leads to data that looks like a series of steps. I know that when there is a step change in the data, that instantaneous data point is valid. The following 9 data points are frozen at the last value, but in reality the pressure is continuing to increase.
I would like to estimate the pressure data between the corners of these steps. I could use diff to identify the data points where the change in value occurs, then interpolate 9 data points between the corners, but that seems like a long way to go. A moving average will smooth the steps out, but it bisects through the middle of the steps. The desired output data is also shown in the below image.

Accepted Answer

David Wilson
David Wilson on 28 Jul 2019
Edited: David Wilson on 28 Jul 2019
How about using interp1 with the 'pchip' option? You did speculate the interpolation is overly complex, but then again it is only one line in Matlab.
First I generate some (fake) data similar to what you have shown.
y = @(x) 320*(1+tanh(x-5));
x = linspace(0,8)';
Ts = 1; % [s]
xi = [0:Ts:8]';
[xs,ys] = stairs(xi, y(xi))
plot(x,y(x), xs, ys, xi, y(xi), 'rs')
Now the ZOH sample & held data is (xi, y(xi)). Using only this data, we reconstruct the higher density data with interp1.
Ts2 = Ts/10;
xi2 = [0:Ts2:8]';
yq = interp1(xi, y(xi), xi2, 'pchip');
plot(xi, y(xi), 'rs', xi2, yq, 'b-')
I use the pchip option to avoid "wobbles" in the interpolation.
test.png

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!