关于数据拟合

昨天做了数据拟合的几道题,复现几张图,见下图所示:

关于数据拟合_第1张图片

拟合结果:


这个图形对原图的拟合还凑合吧!有些差别的原因是自己偷懒,少取了数据点,如果多些数据点效果会更好。

不得不赞matlab集成的cftool工具,真的是太强大了!

说一下,下面程序中的子函数fittedmodel1()为cftool默认保存名称(运行到这一步就知道了)。

clear
clc
%------------------------- p2------------------------------------
%p21
t11=  [0   12  25   50   60     70    90     95    100   150   160   200   250   300   350  400];
tui11=[0.03 0 0.005 0.001 0.001 0.001 0.002 0.003 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 ];
%p22
t12=[0  6  12  18 25 37   50  60  75   100   125    150   160   200   250   300  350    400];
r12=[2 1.7  3   4  2 -0.9 -0.5 0   1   0.5   0.5    0.5   0.5   0.5  0.5    0.5  0.5   0.5].*0.001;
cftool
n=1;
t=0;
dt=0.1;
for i=1:4000
    y11(n)=fittedmodel1(t); %t1,psi1,interpolant,shape-preserving
    t=t+dt;
    n=n+1;
end

n=1;
t=0;
dt=0.1;
for i=1:4000
    y12(n)=fittedmodel2(t); %t12,r12,interpolant,shape-preserving
    t=t+dt;
    n=n+1;
end
figure(1)
subplot(2,1,1)
plot((1:n-1)*dt,y11)
ylabel('纵向推力')
grid on
subplot(2,1,2)
plot((1:n-1)*dt,y12)
ylabel('转艏力矩')
grid on
xlabel('Time(s)')


你可能感兴趣的:(设计)