Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2009-05-25
帖子: 4
声望力: 0 ![]() |
![]()
clc;clear;
x=[-500 -480 -450 -400 -350 -300 -200 -180 -150 -100 -75 -50 -25 0 50 100 125 150 200 220 230 300 350 400 500 600]; y=[0 4 6 10 50 120 150 180 200 400 600 800 1200 1400 1600 1500 1000 800 400 390 300 180 150 50 25 0]; myfunc=inline('0.5*beta(1)*sqrt(3)*erf(sqrt(pi)*beta(2)*x/200)-beta(1)*sqrt(3)*0.5*erf(sqrt(pi)*beta(2)/200*(100-beta(3)-beta(4))','beta','x'); beta=nlinfit(x,y,myfunc,[0.5 1 20 20]); q=beta(1),tanβ=beta(2),s3=beta(3),s4=beta(4) %test the model xx=min(x):max(x); yy=q*sqrt(3)*0.5*erf(sqrt(pi)*tanβ*x/200)-q*sqrt(3)*0.5*erf(sqrt(pi)*tanβ/200*(100-beta(3)-beta(4)); plot(x,y,'o',x,yy,'r') 帮忙怎样修改呢?初学者 baidu的用户可进http://zhidao.baidu.com/question/99432374.html 有加分 |
![]() |
![]() |
![]() |
#2 |
普通会员
注册日期: 2009-02-22
帖子: 91
声望力: 18 ![]() |
![]()
程序里面的β最好换掉,还有erf函数的括号问题!!
clear;clc; x=[-500 -480 -450 -400 -350 -300 -200 -180 -150 -100 -75 -50 -25 0 50 100 125 150 200 220 230 300 350 400 500 600]; y=[0 4 6 10 50 120 150 180 200 400 600 800 1200 1400 1600 1500 1000 800 400 390 300 180 150 50 25 0]; myfunc=inline('0.5*beta(1)*sqrt(3)*erf(sqrt(pi)*beta(2)*x/200)-beta(1)*sqrt(3)*0.5*erf(sqrt(pi)*beta(2)/200*(100-beta(3)-beta(4)))','beta','x'); beta=nlinfit(x,y,myfunc,[0.5 1 20 20]); q=beta(1),tan=beta(2),s3=beta(3),s4=beta(4) %test the model xx=min(x):max(x); yy=q*sqrt(3)*0.5*erf(sqrt(pi)*tan*x/200)-q*sqrt(3)*0.5*erf(sqrt(pi)*tan/200*(100-beta(3)-beta(4))); plot(x,y,'o',x,yy,'r') 希望有帮助!!! |
![]() |
![]() |
![]() |
#3 |
初级会员
注册日期: 2009-05-25
帖子: 4
声望力: 0 ![]() |
![]()
先感谢2楼,虽然代码可以运行了,可是几乎得出的结果是错误的,偏差太大了,是什么原因呢?
|
![]() |
![]() |
![]() |
#4 |
高级会员
注册日期: 2007-06-24
年龄: 70
帖子: 188
声望力: 21 ![]() |
![]()
该组数若用模型:
fx=@(b,x)=b(1)./(1+b(2)*(x-b(3)).^2).^b(4); 则: b=[1690.996, 0.000050379149, 49.067055, 1.7555723] RSS =65750.9048 MSe = 3131 R^2 = 0.98986 |
![]() |
![]() |