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!