Determine the location of max curvature for a set of data
x = linspace(-5,5,100);
y = exp(-x.^2) + sin(x/2);
figure(1)
subplot(131)
plot(x,y,'o');
grid on;
subplot(132)
d1 = diff(y,1)
plot(linspace(-5,5,length(d1)),d1)
grid on;
subplot(133)
d2 = diff(y,2)
plot(linspace(-5,5,length(d2)),d2)
grid on;
tightfig
%
% pp = spline(x,y);
% p_der2 = fnder(pp,2);
% slm = slmengine(x,y)
% d = slmeval(x,slm,2);
% plot(x,d,'-')
% grid on
% 曲线拟合
pp = spline(x,y);
% 求最大曲率及其位置
[fppmax,fppmaxloc] = slmpar(pp,'maxfpp')
fppmax =
1.0405
fppmaxloc =
-1.2626
%求最小曲率及其位置
[fppmin,fppminloc] = slmpar(pp,'minfpp')
fppmin =
-2.0011
fppminloc =
0.050505
|
请发表评论