怎么用MATLAB求多元函数极值求z=x^2-(y-1)^2的极值,包括极大值和极小值,用MATLAB怎么编程?
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/27 06:46:35
怎么用MATLAB求多元函数极值求z=x^2-(y-1)^2的极值,包括极大值和极小值,用MATLAB怎么编程?
怎么用MATLAB求多元函数极值
求z=x^2-(y-1)^2的极值,包括极大值和极小值,用MATLAB怎么编程?
怎么用MATLAB求多元函数极值求z=x^2-(y-1)^2的极值,包括极大值和极小值,用MATLAB怎么编程?
用fminsearch函数
格式 (x,feval,exitflag,output)=fminsearch(fun,x0,p1,p2,..)
x为函数fun在x0处的极值
x0为x的初值
exitflag,output为相关参数
p1 p2为函数的参数
f = @(x,y)x(1)^2-(x(2)-1)^2
>> [x,fvalue,flag,output]=fminsearch(f,[0,0])
Exiting: Maximum number of function evaluations has been exceeded
- increase MaxFunEvals option.
...
全部展开
f = @(x,y)x(1)^2-(x(2)-1)^2
>> [x,fvalue,flag,output]=fminsearch(f,[0,0])
Exiting: Maximum number of function evaluations has been exceeded
- increase MaxFunEvals option.
Current function value: -359212266339440800000000000000000000000000000000000000000000000000000000000000000000.000000
x =
1.0e+041 *
0.9523 -6.0686
fvalue =
-3.5921e+083
flag =
0
output =
iterations: 200
funcCount: 401
algorithm: 'Nelder-Mead simplex direct search'
message: [1x233 char]
收起