请教一个关于fminunc非线性优化问题。
Show older comments

问题:我想用matlab求解该题模型的最小值,但是编写的程序一直报错,好像是fminunc函数的使用问题。
这是我的程序:
function main()
a = [10^(-6), 0, 0;
0, 2, 0;
0, 0, 3];
U = [1, 0, 0;
0, 1/2, -sqrt(3)/2;
0, sqrt(3)/2, 0.5];
global A
A = U*a*(U') %题目中的A
global b
b = [0,0,0]'
x0 = [0,0,0]'
[x, y] = fminunc('fun1', x0)
function f = fun1(x)
f = norm(A*[x(1),x(2),x(3)]'-b, 2); %目标优化函数
错误使用 feval
未定义与 'double' 类型的输入参数相对应的函数 'fun1'。
出错 fminunc (line 262)
f = feval(funfcn{3},x,varargin{:});
出错 linprog_test (line 13)
[x, y] = fminunc('fun1', x0)
原因:
Failure in initial user-supplied objective function evaluation. FMINUNC cannot continue.
Accepted Answer
More Answers (0)
Categories
Find more on 求解器输出和迭代输出 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!