I wrote this code and I got this error. (Warning: 8 equations in 4 variables. Warning: Explicit solution could not be found.) How can I fix it?

조회 수: 1 (최근 30일)
syms x1 x2 x3 r ll
f=3*(x1+1)+4*(x2-1)+(x3-1);
g=3*x1+4*x2+x3-1;
L=f-r*g;
gradL=gradient(L);
[x1s x2s x3s rs]=solve(gradL==0,[x1 x2 x3 r],'Real',true);
h=.01;
k=.01;
for i=1:numel(x1s)
fopt=double(subs(f,[x1 x2 x3],[x1s(i) x2s(i) x3s(i)]));
gc=subs(g,[x1 x2 x3],[x1s(i)+h x2s(i)+k x3s(i)+ll]);
l=double(solve(gc==0,ll));
[a j]=min(abs(l));
l=l(j);
fnear=double(subs(f,[x1 x2 x3],[x1s(i)+h x2s(i)+k x3s(i)+l]));
[x1s(i) x2s(i) x3s(i)]
fopt=sqrt(fopt)
if fopt<fnear
disp('min')
elseif fopt>fnear
disp('max')
end
end
Warning: 8 equations in 4 variables.
> In C:\Program Files\MATLAB\R2013a\toolbox\symbolic\symbolic\symengine.p>symengine at 56
In mupadengine.mupadengine>mupadengine.evalin at 97
In mupadengine.mupadengine>mupadengine.feval at 150
In solve at 172
In problem1 at 11
Warning: Explicit solution could not be found.
> In solve at 179
In problem1 at 11

채택된 답변

Salahuddin Bangash
Salahuddin Bangash 2018년 12월 16일
ans = [ 1/3, 0, 0]
fopt =0.0000 + 1.0000i
max
Are you sure there is an error? i'm using R2016a

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by