matlab程序如何查错,请大家看看这个MATLAB程序哪里出了错?如何改?

问题

1 objfun的;改为半角;

2matlab 不识别 confun中ln 改为log

3fmincon vlb vub没定义 改为lb ub

----------------------------

function f=objfun(x)

f=pi*(4.14*x(1)+2.5)^2*x(2)*x(3)^2/4;

--------------------------------------

function [c,ceq]=confun(x)

c=[6.35*10^5-x(1)^2*x(2)*x(3)^2;13432.29*(4.69-0.63*log(x(1)))-x(1)*x(2)*x(3)^2];

ceq=[];

-------------------------------------

上面两个函数存为.m文件

命令窗口输入

A=[0 -1 5;0 1 -17];

b=[0;0];

lb=[17;10;2];

ub=[50;100;6];

x0=[17;87;5];

[x,fval]=fmincon(@objfun,x0,A,b,[],[],lb,ub,@confun)

Warning: Trust-region-reflective algorithm does not solve this type of problem, using

active-set algorithm. You could also try the interior-point algorithm: set the

Algorithm option to 'interior-point' and rerun.

> In fmincon at 460

Local minimum possible. Constraints satisfied.

fmincon stopped because the size of the current search direction is less than

twice the default value of the step size tolerance and constraints were

satisfied to within the default value of the constraint tolerance.

Active inequalities (to within options.TolCon = 1e-006):

lower upper ineqlin ineqnonlin

1 2

x =

17.000000000000000

86.941482536032794

5.138256344408354

fval =

9.575582120628687e+006

再问: 我按照你的写,可还是说: ??? Attempt to execute SCRIPT fmincon as a function. 会不会是我的软件有问题?

再答: 你的是什么版本 的,要不QQ聊吧

再问: matlab 7.0。你的QQ?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值