MATLAB Answers

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

2 ビュー (過去 30 日間)
Ryan
Ryan 2019 年 7 月 28 日
編集済み: David Wilson 2019 年 7 月 28 日
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.

  0 件のコメント

サインインしてコメントする。

採用された回答

David Wilson
David Wilson 2019 年 7 月 28 日
編集済み: David Wilson 2019 年 7 月 28 日
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

  0 件のコメント

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by