我如何在原始数据下获得一条线

时间:2018-08-06 12:01:53

标签: matlab

我只有黑线的数据,我想得到黄色区域。 那么如何在MATLAB上获得红线呢? 请帮助我。

Sample

1 个答案:

答案 0 :(得分:0)

尝试以下示例:

%create a sample periodic curve
t=0:.1:31.4;
upper = (100-t.^2).*cos(t+pi);

%take first derivative of the curve
diff1 = diff(upper);

%find the lowest points of the original curve
lower_x = find([diff1>0 0] & [0 diff1<0]); %rising zero crossings
lower_y = upper(lower_x);

%interpolate between points of the lower curve
lower = spline(lower_x,lower_y,0:size(t,2)-1);

%display
figure; hold on;
plot(t,upper,'b');
plot(t,lower,'r');