1.最小二乘算法Matlab程序 算法假定某天的气温变化记录如表所示时间(t)0\x051\x052\x053\x054\x055\x056\x057\x058\x059\x0510\x0511\x0512温度(x(t))\x0515\x0514\x0514\x0514\x0514\x0515\x0516\x0518\x0520\x0522\x0523\x0525\x0528

来源:学生作业帮助网 编辑:作业帮 时间:2024/12/01 00:33:45
1.最小二乘算法Matlab程序 算法假定某天的气温变化记录如表所示时间(t)0\x051\x052\x053\x054\x055\x056\x057\x058\x059\x0510\x0511\x0512温度(x(t))\x0515\x0514\x0514\x0514\x0514\x0515\x0516\x0518\x0520\x0522\x0523\x0525\x0528
xTaO`+mo۵ _h td Sd 2H!q6L߶|/x} `hbb{ݵT?:;*8들^[ vVWolr+y*2L$5gswݵS_rX" oj|_&;Vy5[奇"!4t919Z;T<8\SJ(%l&4;>X {oV-mFX!_äuP]⦱W.Sgwq@utJ]IN1ܫ-K)¼ܭ*;YWLcHo?yw=vFmwd|af~Ţd"49c38 J|Jq N3vgX/I 2@4$̠se,!!E@5Icd *$I:EH@j"P:1k߀e i33Md x cI3!AKhjopvaNF5p@$pvvS"rsрn=>?Wwl#s$e^<c* nn,H}nw͒ÒAdvT)&s;R8 $s+'$3m_ +{\n~O2N\+zͤd'W

1.最小二乘算法Matlab程序 算法假定某天的气温变化记录如表所示时间(t)0\x051\x052\x053\x054\x055\x056\x057\x058\x059\x0510\x0511\x0512温度(x(t))\x0515\x0514\x0514\x0514\x0514\x0515\x0516\x0518\x0520\x0522\x0523\x0525\x0528
1.最小二乘算法Matlab程序 算法
假定某天的气温变化记录如表所示
时间(t)0\x051\x052\x053\x054\x055\x056\x057\x058\x059\x0510\x0511\x0512
温度(x(t))\x0515\x0514\x0514\x0514\x0514\x0515\x0516\x0518\x0520\x0522\x0523\x0525\x0528
时间(t)\x0513\x0514\x0515\x0516\x0517\x0518\x0519\x0520\x0521\x0522\x0523\x0524\x05
温度(x(t))\x0531\x0532\x0531\x0529\x0527\x0525\x0524\x0522\x0520\x0518\x0517\x0516\x05
试用最小二乘法确定这一天的气温变化规律.

1.最小二乘算法Matlab程序 算法假定某天的气温变化记录如表所示时间(t)0\x051\x052\x053\x054\x055\x056\x057\x058\x059\x0510\x0511\x0512温度(x(t))\x0515\x0514\x0514\x0514\x0514\x0515\x0516\x0518\x0520\x0522\x0523\x0525\x0528
原贴请看:
>> clear
>> f=inline('a(1)*x+a(2)*x.^2.*exp(-a(3)*x)+a(4)','a','x');
x=[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
y=[2.3201 2.6470 2.9707 3.2885 3.6008 3.9090 4.2147 4.5191 4.8232 5.1275];
[xx,res]=lsqcurvefit(f,ones(1,4),x,y);
xx',res
要建立也是可以的.就是把上面那个inline弄成.m
如下:
在Matlab下输入:edit zhidao_15.m,然后将下面两行百分号之间的内容,复制进去,保存
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function y=zhidao_15(a,x)
y=a(1)*x+a(2)*x.^2.*exp(-a(3)*x)+a(4);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
在Matlab下面输入:
x=[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
y=[2.3201 2.6470 2.9707 3.2885 3.6008 3.9090 4.2147 4.5191 4.8232 5.1275];
[xx,res]=lsqcurvefit('zhidao_15',ones(1,4),x,y);
xx',res