24小时热门版块排行榜    

查看: 2467  |  回复: 10
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

beina

新虫 (正式写手)

[求助] 需要用matlab拟合数据的外行人急需帮助

我有一函数y=f(x),里面有个未知数k,还有个x,y数值的txt文件,用这些条件求k
首先建立了一个M文件,
function F=myfun(x,xdata)
F=0.6518 + 0.7713./atan(xdata) - 0.0911*atan(xdata) + ((0.9121* xdata + 1.572)./(0.9121* xdata + 1.59 + 2.3026./ xdata + 0.0637*log(1 + 15.7./ xdata)) - 1)./((1 + 5.04*x* xdata).*(1 + (x^0.674)* (xdata.^0.173)));
然后就运行下面的命令:
>> load data.txt
>> xdata=data(:,1);
>> ydata=data(:,2);
>> x=lsqcurvefit(@myfun,0.05,xdata,ydata)
然后就有错误了
??? Error using ==> qr
Complex sparse QR is not yet available.

Error in ==> aprecon at 57
   RPCMTX = qr(TM(:,p));

Error in ==> trdog at 47
         [R,permR] = feval(pcmtx,H,pcoptions,DM,DG,varargin{:});

Error in ==> snls at 346
      [sx,snod,qp,posdef,pcgit,Z] = trdog(x,g,A,D,delta,dv,...

Error in ==> lsqncommon at 285
    [x,FVAL,LAMBDA,JACOB,EXITFLAG,OUTPUT,msg]=...

Error in ==> lsqcurvefit at 186
[x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...

这是哪里的错误呢, lsqcurvefit 的运用中有木有语法错误,哪位大侠可以帮我解答一下,感激涕零,如果能帮我跑一下程序就最好不过了……
回复此楼
流泪撒种的,必欢呼收割
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖


感谢参与,应助指数 +1
jjdg(金币+1): 感谢支持 2011-12-26 13:32:54
检查下数据,可能在计算过程中出现了复数,是不是去对数时,底数出现了负数
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
2楼2011-12-26 10:48:56
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 beina 的主题更新
信息提示
请填处理意见