| 查看: 2177 | 回复: 11 | ||
[求助]
好心虫友,帮忙看看这个matlab程序那里出错了 已有1人参与
|
||
|
用matlab拟合数据,进行NRTL模型拟合:我编写了如下的程序,一直出错,麻烦有懂的虫友帮忙看看,怎么改错?? (一)定义.m文件。 function g4=f(beta0,x1,x2,T,R) g1=beta0(1); g2=beta0(2); g3=beta0(3); g4=beta0(4); g4=x2.*x2.*((((g(1)./(R.*T)).*(exp(-g(3).*g(1)./(R.*T))).^2)./((x1+(exp(-g(3).*g(1)./(R.*T))).*x2).^2))+(((g(2)./(R.*T)).*(exp(-g(3).*g(2)./(R.*T))).^2)./((x2+(exp(-g(3).*g(2)./(R.*T))).*x1).^2))) (二)编写程序。 x1=[0.01525 0.02059 0.02685 0.03417 0.04221 0.04958]; x2=[0.98475 0.97941 0.97315 0.96583 0.95779 0.95042]; T=[298.15 303.15 308.15 313.15 318.15 323.15]; R=[8.314 8.314 8.314 8.314 8.314 8.314]; beta0=[0,0,0,0]; [g,resnorm]=lsqcurvefit(@f,beta0,x1,x2,T,R) 运行后出错: Warning: Length of lower bounds is > length(x); ignoring extra bounds. > In checkbounds at 27 In optim\private\lsqncommon at 39 In lsqcurvefit at 149 In Untitled2 at 6 Warning: Length of upper bounds is > length(x); ignoring extra bounds. > In checkbounds at 37 In optim\private\lsqncommon at 39 In lsqcurvefit at 149 In Untitled2 at 6 Exiting due to infeasibility: 4 lower bounds exceed the corresponding upper bounds. g = 0 0 0 0 resnorm = [] |
» 猜你喜欢
医学类期刊求推荐
已经有5人回复
生活琐事由它去
已经有4人回复
提交了我也来说说感想
已经有12人回复
青B发送上会通知了吗
已经有9人回复
西安交大新媒学院副院长用撤稿论文结题
已经有6人回复
论文撤稿了
已经有8人回复
化学专业申博
已经有4人回复
某211大学教师把个人教师官方主页改成:我跑了我跑了我跑了!官宣跑路!
已经有5人回复
26/27申博自荐
已经有9人回复
博士申请
已经有3人回复
2楼2017-07-09 17:29:24
3楼2017-07-09 17:49:08
4楼2017-07-09 17:49:43
5楼2017-07-09 18:04:44
6楼2017-07-09 18:07:54
|
那我初始值就定义4个可以吗?我按照你说的改了程序,把初始值改为【1,1,0.3,1】不再为0,结果出来后就是Warning: Length of lower bounds is > length(x); ignoring extra bounds. > In checkbounds at 27 In optim\private\lsqncommon at 39 In lsqcurvefit at 149 In Untitled2 at 6 Warning: Length of upper bounds is > length(x); ignoring extra bounds. > In checkbounds at 37 In optim\private\lsqncommon at 39 In lsqcurvefit at 149 In Untitled2 at 6 Exiting due to infeasibility: 4 lower bounds exceed the corresponding upper bounds. g = 1.0000 1.0000 0.3000 1.0000 resnorm = [] 就是我定义的值,我也把公式做了改变的g4=exp(x2.*x2.*((((g(1)./(R.*T)).........) |
7楼2017-07-09 18:40:34
|
我再把我现在的程序发一遍完整的,这样子不会乱。 m文件: function g4=f(beta0,x1,x2,T,R) g1=beta0(1); g2=beta0(2); g3=beta0(3); g4=beta0(4); g4=exp(x2.*x2.*((((g(1)./(R.*T)).*(exp(-g(3).*g(1)./(R.*T))).^2)./((x1+(exp(-g(3).*g(1)./(R.*T))).*x2).^2))+(((g(2)./(R.*T)).*(exp(-g(3).*g(2)./(R.*T))).^2)./((x2+(exp(-g(3).*g(2)./(R.*T))).*x1).^2)))) 程序代码: x1=[0.01525 0.02059 0.02685 0.03417 0.04221 0.04958]; x2=[0.98475 0.97941 0.97315 0.96583 0.95779 0.95042]; T=[298.15 303.15 308.15 313.15 318.15 323.15]; R=[8.314 8.314 8.314 8.314 8.314 8.314]; beta0=[1,1,0.3,1]; [g,resnorm]=lsqcurvefit(@f,beta0,x1,x2,T,R) 运行后输出: Warning: Length of lower bounds is > length(x); ignoring extra bounds. > In checkbounds at 27 In optim\private\lsqncommon at 39 In lsqcurvefit at 149 In Untitled2 at 6 Warning: Length of upper bounds is > length(x); ignoring extra bounds. > In checkbounds at 37 In optim\private\lsqncommon at 39 In lsqcurvefit at 149 In Untitled2 at 6 Exiting due to infeasibility: 4 lower bounds exceed the corresponding upper bounds. g = 1.0000 1.0000 0.3000 1.0000 resnorm = [] 就是初始值定义什么就出什么。 或者这个应该怎么写呢? |
8楼2017-07-09 18:53:25
9楼2017-07-09 20:41:12
10楼2017-07-09 22:47:46












回复此楼