fmincon error occurs without details in Matlab
1 view (last 30 days)
Show older comments
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 Comments
Answers (2)
Sulaymon Eshkabilov
on 11 Nov 2021
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 Comments
Matt J
on 11 Nov 2021
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 Comments
See Also
Categories
Find more on Linear Least Squares 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!