matlab最小二乘法曲线拟合 m文件错误在哪x=10000:1000:23000;y=[24.0,26.5,29.8,32.4,34.7,41.1,42.8,44.6,47.3,65.8,87.5,137.8,174.2];dy=1.5;for n=1:6[a,S]=polyfit(x,y,n);A{n}=a;da=dy*sqrt(diag(inv(S.R'*S.R)));DA{n}= da';freedom(n)=S.df;[ye,

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 12:46:41
matlab最小二乘法曲线拟合m文件错误在哪x=10000:1000:23000;y=[24.0,26.5,29.8,32.4,34.7,41.1,42.8,44.6,47.3,65.8,87.5,1

matlab最小二乘法曲线拟合 m文件错误在哪x=10000:1000:23000;y=[24.0,26.5,29.8,32.4,34.7,41.1,42.8,44.6,47.3,65.8,87.5,137.8,174.2];dy=1.5;for n=1:6[a,S]=polyfit(x,y,n);A{n}=a;da=dy*sqrt(diag(inv(S.R'*S.R)));DA{n}= da';freedom(n)=S.df;[ye,
matlab最小二乘法曲线拟合 m文件错误在哪
x=10000:1000:23000;
y=[24.0,26.5,29.8,32.4,34.7,41.1,42.8,44.6,47.3,65.8,87.5,137.8,174.2];
dy=1.5;
for n=1:6
[a,S]=polyfit(x,y,n);
A{n}=a;
da=dy*sqrt(diag(inv(S.R'*S.R)));
DA{n}= da';
freedom(n)=S.df;
[ye,delta]=polyval(a,x,S);
YE{n}=ye;
D{n}=delta;
chi2(n)=sum((y-ye).^2)/dy/dy;
end
Q=1-chi2cdf(chi2,freedom);
clf,shg
subplot(1,2,1),plot(1:6,abs(chi2-freedom),'b')
xlabel('阶次'),title('chi2与自由度')
subpolt(1,2,2),plot(1:6,Q,'r',1:6,ones(1,6)*0.5)
xlabel('阶次'),title('Q与0.5线')
nod=input('根据图形选择适当的阶次(请输入数值)');
clf,shg,
plot(x,y,'kx');
xlabel('x'),ylabel('y');
axis([8000,23000,20.0,174.2]);hold on
error(x,YE{nod},D{nod,'r'});hold off
title('较适合阶次的拟合')
text(10000,150.0,['chi2='num2str(chi2(nod))'~1'int2str(freedom(nod))])
text(10000,140.0.['freedom='int2str(freedom(nod))])
text(2000,40.0,['Q='num2str(Q(nod))'~0.5'])
disp()
disp('拟合多项式系数'),diap(A{nod})
disp('拟合多项式离差'),disp(DA{nod})
第28行出错了,

matlab最小二乘法曲线拟合 m文件错误在哪x=10000:1000:23000;y=[24.0,26.5,29.8,32.4,34.7,41.1,42.8,44.6,47.3,65.8,87.5,137.8,174.2];dy=1.5;for n=1:6[a,S]=polyfit(x,y,n);A{n}=a;da=dy*sqrt(diag(inv(S.R'*S.R)));DA{n}= da';freedom(n)=S.df;[ye,
你程序里的28行是这个吗text(10000,150.0,['chi2='num2str(chi2(nod))'~1'int2str(freedom(nod))])
看不出来有没有空格啊text(10000,150.0,['chi2=' num2str(chi2(nod)) '~1' int2str(freedom(nod))])
报的什么错误,输入的nod没有越界吧

最小二乘法曲线拟合代码 各位大哥大姐,能不能帮我用matlab编写一个最小二乘法曲线拟合的M文件啊,我的意思是当输入两组数据以后,运行后能出来拟合图像还有函数表达式,比如输入x=[1,2,3,4,5] y=[500.6,442.4,428.6,370.1,343.1] 最小二乘法曲线拟合的实例,用matlab实现的例子,不用polyfit实现的例子.急用! matlab最小二乘法曲线拟合 m文件错误在哪x=10000:1000:23000;y=[24.0,26.5,29.8,32.4,34.7,41.1,42.8,44.6,47.3,65.8,87.5,137.8,174.2];dy=1.5;for n=1:6[a,S]=polyfit(x,y,n);A{n}=a;da=dy*sqrt(diag(inv(S.R'*S.R)));DA{n}= da';freedom(n)=S.df;[ye, matlab的数据曲线拟合 matlab 怎样运行m文件? Matlab最小二乘法曲线拟合用Matlab做曲线拟合,已知x、y的值,但不知道拟合阶数,采样才能依据已有值拟合出最合适的曲线呢? 一运行出现了这个 ? Error: File: nafit.m Line: 16 Column: 1 Unexpected MATLAB operator.% 6.7.2 曲线拟合最小二乘法function p=nafit(x,y,m)% 多项式拟合% p=nafit(x,y,m), x,y 为数据向量,m为拟合多项式次数% p返回多项式 最小二乘法的matlab程序 matlab实现最小二乘法的曲线拟合与直线拟合的比较,并对比两种拟合算法的误差有没有程序啊 不用cftool 满意后加分 matlab画出散点图后如何用曲线拟合 如何利用matlab进行曲线拟合 matlab中如何进行曲线拟合 请问你知道什么是曲线拟合的最小二乘法吗? 什么书的第03章是曲线拟合的最小二乘法 matlab M文件怎么运行啊, matlab的m文件怎么运行啊? 如何在matlab中创建m文件