Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2011-05-08
住址: 北京
年龄: 34
帖子: 1
声望力: 0 ![]() |
![]()
想拟合一个函数的,用最小二乘曲线拟合,感觉代码木有错,但是编译报错,求解答,谢谢
报错如下: ??? Error: File: zuixiaoerchengfa.m Line: 34 Column: 1 Function definitions are not permitted in this context. 代码如下: x=1:1:12; y=[3.9 5.3 7.2 9.6 12.9 17.1 23.2 31.4 38.6 50.2 62.9 76.0]; function y=c8f3(a,x) %line 34 错误报告说这行错了 y=a(1).*exp(a(2)*x); a=lsqcurvefit('c8f3',[1;2;2;3],x,y); a' y1=c8f3(a,x); plot(x,y,x,y1,'o') ![]() ![]() |
![]() |
![]() |