24小时热门版块排行榜    

查看: 391  |  回复: 0

shijipei

铜虫 (初入文坛)

[求助] 悬赏金币求助matlab自定义函数拟合曲线

自定义一个函数去拟合曲线,运行了总是报错,
??? Error using ==> times
Matrix dimensions must agree.

Error in ==> dig at 14
a21=5140.*h1.*exp(k12.*xdata);
求助高手指点下

ydata1=[0 10 20 30 40 50 60 70 80 90 100];
ydata2=[0 0.07 0.15 0.25 0.35 0.49 0.59 0.72 0.91 1.14 1.47];
x0=[1/10 0.08 1/20];
options=[]; % default settings
options(1)=1; % tabular display some intermediate results
options(2)=1.e-4; % controls the accuracy of x at the solution
options(3)=1.e-4; % controls the accuracy of f at the solution
options(5)=1; % Gauss-Newton algorithum which is faster when residual is small
options(14)=10000; % maximum number of function evaluations
x=leastsq('dig',x0,options,[],ydata1,ydata2);

function [ y1 ] = dig(tor,k12,kv)
k21=0.816*k12;
A20=11000;
d=0.14*tor;g=k12/(k12+k21);h1=k21/(k12+k21);
a21=5140.*h1.*exp(k12.*xdata)*exp(d*xdata);
a22=(4685.*g-455.*h1).*exp(kv.*xdata);
y1 = a21+a22;
回复此楼
希望在这里可以学到更多知识,大家多指教哦。
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

找到一些相关的精华帖子,希望有用哦~

科研从小木虫开始,人人为我,我为人人
相关版块跳转 我要订阅楼主 shijipei 的主题更新
信息提示
请填处理意见