fmincon error occurs without details in Matlab
1 次查看(过去 30 天)
显示 更早的评论
I followed the instructions, but what I only can get is "error in (filename)" without any additional details. Could you tell me which part made an error?
clear;clc;lb = [0,0];
ub = [1,1];
A = [1 1];
B = [1];
Aeq = [];
Beq = [];
x0=[0.5, 0.5];
f=@(x)(200*x(1)-37)^2+(200*x(2)-83)^2+(200*x(1)+200*x(2)-122)^2+(400*x(1)-82)^2+(400*x(2)-157)^2+(400*x(1)+400*x(2)-250)^2;
x = fmincon(f,x0,A,B,Aeq,Beq,lb,ub)
0 个评论
回答(2 个)
Sulaymon Eshkabilov
2021-11-11
It is working ok.
clearvars;clc;
lb = [0, 0];
ub = [1, 1];
A = [1 1];
B = 1;
Aeq = [];
Beq = [];
x0=[0.5, 0.5];
f=@(x)(200*x(1)-37)^2+(200*x(2)-83)^2+(200*x(1)+200*x(2)-122)^2+(400*x(1)-82)^2+(400*x(2)-157)^2+(400*x(1)+400*x(2)-250)^2;
x = fmincon(f,x0,A,B,Aeq,Beq,lb,ub)
0 个评论
Matt J
2021-11-11
lsqlin would be better for this than fmincon.
lb = [0,0];
ub = [1,1];
A = [1 1];
b = [1];
C=[200,0;
0 200;
200 200;
400 0;
0 400;
400 400];
d=[ 37 83 122 82 157 250].';
lsqlin(C,d, A,b,[],[],lb,ub)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Least Squares 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!