matlab数据拟合老出错是怎么回事?
clc;cleardata=load('市镇乡.txt');x1=data(:,1)'/10000;x2=data(:,2)'/10000;x3=data(:,3)'/1...
clc;clear
data=load('市镇乡.txt');
x1=data(:,1)'/10000;
x2=data(:,2)'/10000;
x3=data(:,3)'/10000;%数据没问题啊,我检验过
r=0:90;
fun=inline('a(1)*exp( -((a(2)-r)/a(3))^2 )','a','r');
a=nlinfit(r,x1,fun,[32, 30.09, 38.69]);
X1=a(1)*exp( -( (a(2)-r)/a(3) )^2 );
plot(t,x1,'o',t,X1);
284746.88 202044.15 840255.24
210324.4 159711.09 685471.38
249153.52 178953.39 759177.98
262096.56 196271.46 810772.6
291218.4 209741.07 847625.9
268568.08 213589.53 854996.56
310632.96 234756.06 943444.48
313868.72 228983.37 965556.46
323576 234756.06 1031892.4
323576 255922.59 1112969.66
352697.84 259771.05 1149822.96
342990.56 279013.35 1245641.54
362405.12 273240.66 1341460.12
375348.16 294407.19 1437278.7
462713.68 380997.54 1820553.02
498307.04 363679.47 1695251.8
501542.8 357906.78 1496243.98
550079.2 377149.08 1496243.98
478892.48 300179.88 1230900.22
397998.48 209741.07 965556.46
375348.16 196271.46 943444.48
410941.52 190498.77 884479.2
511250.08 234756.06 1009780.42
462713.68 228983.37 928703.16
430356.08 238604.52 921332.5
488599.76 269392.2 950815.14
501542.8 280937.58 958185.8
465949.44 277089.12 869737.88
546843.44 330967.56 1017151.08
537136.16 323270.64 1017151.08
601851.36 359831.01 1208788.24
640680.48 369452.16 1179305.6
669802.32 400239.84 1282494.84
679509.6 407936.76 1341460.12
数据放不下91组,我随便来了些,关键是能出图形就好 大神求救啊~~~~~ 展开
data=load('市镇乡.txt');
x1=data(:,1)'/10000;
x2=data(:,2)'/10000;
x3=data(:,3)'/10000;%数据没问题啊,我检验过
r=0:90;
fun=inline('a(1)*exp( -((a(2)-r)/a(3))^2 )','a','r');
a=nlinfit(r,x1,fun,[32, 30.09, 38.69]);
X1=a(1)*exp( -( (a(2)-r)/a(3) )^2 );
plot(t,x1,'o',t,X1);
284746.88 202044.15 840255.24
210324.4 159711.09 685471.38
249153.52 178953.39 759177.98
262096.56 196271.46 810772.6
291218.4 209741.07 847625.9
268568.08 213589.53 854996.56
310632.96 234756.06 943444.48
313868.72 228983.37 965556.46
323576 234756.06 1031892.4
323576 255922.59 1112969.66
352697.84 259771.05 1149822.96
342990.56 279013.35 1245641.54
362405.12 273240.66 1341460.12
375348.16 294407.19 1437278.7
462713.68 380997.54 1820553.02
498307.04 363679.47 1695251.8
501542.8 357906.78 1496243.98
550079.2 377149.08 1496243.98
478892.48 300179.88 1230900.22
397998.48 209741.07 965556.46
375348.16 196271.46 943444.48
410941.52 190498.77 884479.2
511250.08 234756.06 1009780.42
462713.68 228983.37 928703.16
430356.08 238604.52 921332.5
488599.76 269392.2 950815.14
501542.8 280937.58 958185.8
465949.44 277089.12 869737.88
546843.44 330967.56 1017151.08
537136.16 323270.64 1017151.08
601851.36 359831.01 1208788.24
640680.48 369452.16 1179305.6
669802.32 400239.84 1282494.84
679509.6 407936.76 1341460.12
数据放不下91组,我随便来了些,关键是能出图形就好 大神求救啊~~~~~ 展开
2个回答
展开全部
感谢楼上,自己把它给弄出来了,嘿嘿
主要是忘了x是向量,要 点平方~
a(1)*exp( -((a(2)-r)/a(3))^2 改成
a(1)*exp( -((a(2)-r)/a(3))^.2
另外
plot(t,x1,'o',t,X1);改成
plot(r,x1,'o',r,X1);
ok
主要是忘了x是向量,要 点平方~
a(1)*exp( -((a(2)-r)/a(3))^2 改成
a(1)*exp( -((a(2)-r)/a(3))^.2
另外
plot(t,x1,'o',t,X1);改成
plot(r,x1,'o',r,X1);
ok
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询