matlab 中fit函数怎么用?求例子

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/11 04:54:07

matlab 中fit函数怎么用?求例子
matlab 中fit函数怎么用?求例子

matlab 中fit函数怎么用?求例子

看matlab自己的例子,help里边例子很丰富哈~~~


load census

plot(cdate,pop,'o')

hold on

s = fitoptions('Method','NonlinearLeastSquares',...

               'Lower',[0,0],...

               'Upper',[Inf,max(cdate)],...

               'Startpoint',[1 1]);

f = fittype('a*(x-b)^n','problem','n','options',s);

[c2,gof2] = fit(cdate,pop,f,'problem',2);

[c3,gof3] = fit(cdate,pop,f,'problem',3);

plot(c2,'m')

plot(c3,'c')



画出的图来: