24小时热门版块排行榜    

查看: 2871  |  回复: 11

492990274

铁杆木虫 (正式写手)

[求助] matlab求三元二次函数最大值

急求用matlab求三元二次函数最大值的编程语句!
急!
函数如:
y=100+30A+78B+90C-1.4A^2+7.2B^2-9.53C^2+0.84AB+0.48BC-9.39BC
请将具体命令写出,谢谢,谢谢~
回复此楼
渴望改变~
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

感谢参与,应助指数 +1
不给定ABC的取值范围,这个函数的最大值可能是无穷大啊
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楼2012-11-27 09:17:07
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★
492990274: 金币+10, ★★★★★最佳答案, 非常感谢~ 2012-11-27 19:53:05
xzhdty: 金币+2, 谢谢参与 2012-11-27 20:53:49
>> y=@(x)100+30*x(1)+78*x(2)+90*x(3)-1.4*x(1).^2+7.2*x(2).^2-9.53*x(3).^2+...
0.84*x(1)*x(2)+0.48*x(1)*x(3)-9.39*x(2)*x(3);
X = fminsearch(@(x) y(x),[0.3 1 1])

Exiting: Maximum number of function evaluations has been exceeded
         - increase MaxFunEvals option.
         Current function value: -48992246282801925000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000


X =

  1.0e+051 *

    0.1933   -1.2573   -1.9638
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.
3楼2012-11-27 09:31:30
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

引用回帖:
3楼: Originally posted by dbb627 at 2012-11-27 09:31:30
>> y=@(x)100+30*x(1)+78*x(2)+90*x(3)-1.4*x(1).^2+7.2*x(2).^2-9.53*x(3).^2+...
0.84*x(1)*x(2)+0.48*x(1)*x(3)-9.39*x(2)*x(3);
X = fminsearch(@(x) y(x),)

Exiting: Maximum number of function ...

这个写的有点问题,求最大值,将y前面乘个负号
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.
4楼2012-11-27 09:33:40
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

492990274

铁杆木虫 (正式写手)

引用回帖:
3楼: Originally posted by dbb627 at 2012-11-27 09:31:30
>> y=@(x)100+30*x(1)+78*x(2)+90*x(3)-1.4*x(1).^2+7.2*x(2).^2-9.53*x(3).^2+...
0.84*x(1)*x(2)+0.48*x(1)*x(3)-9.39*x(2)*x(3);
X = fminsearch(@(x) y(x),)

Exiting: Maximum number of function ...

请问[0.3 1 1]在这里是限定了x的范围吗?
渴望改变~
5楼2012-11-27 10:58:19
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

引用回帖:
5楼: Originally posted by 492990274 at 2012-11-27 10:58:19
请问在这里是限定了x的范围吗?...

这个是计算的x的初值,不是x的范围
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.
6楼2012-11-27 11:02:21
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

492990274

铁杆木虫 (正式写手)

引用回帖:
3楼: Originally posted by dbb627 at 2012-11-27 09:31:30
>> y=@(x)100+30*x(1)+78*x(2)+90*x(3)-1.4*x(1).^2+7.2*x(2).^2-9.53*x(3).^2+...
0.84*x(1)*x(2)+0.48*x(1)*x(3)-9.39*x(2)*x(3);
X = fminsearch(@(x) y(x),)

Exiting: Maximum number of function ...

试了一下,运行不了,@(x)是什么算法?
渴望改变~
7楼2012-11-27 11:22:30
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

引用回帖:
7楼: Originally posted by 492990274 at 2012-11-27 11:22:30
试了一下,运行不了,@(x)是什么算法?...

你的matlab是什么版本的
@(x)是函数句柄
6.5级以下版本不能运行。
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.
8楼2012-11-27 14:25:29
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

492990274

铁杆木虫 (正式写手)

引用回帖:
6楼: Originally posted by dbb627 at 2012-11-27 11:02:21
这个是计算的x的初值,不是x的范围...

初值不一样,结果差很多,该怎么设置初值?另外,要怎样给x1,x2,x3设置范围?谢谢啦~
渴望改变~
9楼2012-11-27 19:49:25
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★ ★ ★ ★
492990274: 金币+5, ★★★★★最佳答案 2012-11-28 20:14:38
可以使用X = fmincon(FUN,X0,A,B,Aeq,Beq,LB,UB)

y=@(x)-(100+30*x(1)+78*x(2)+90*x(3)-1.4*x(1).^2+7.2*x(2).^2-9.53*x(3).^2+...
0.84*x(1)*x(2)+0.48*x(1)*x(3)-9.39*x(2)*x(3));
X0=;%ABC计算初值
LB=;%ABC下限
UB=;%ABC上限

X = fmincon(@(x)y(x),X0,[],[],[],B[],LB,UB)
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.
10楼2012-11-27 20:53:10
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 492990274 的主题更新
信息提示
请填处理意见