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 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Busra Tabak
le 15 Déc 2018
Commenté : Busra Tabak
le 16 Déc 2018
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
0 commentaires
Réponse acceptée
Salahuddin Bangash
le 16 Déc 2018
ans = [ 1/3, 0, 0]
fopt =0.0000 + 1.0000i
max
Are you sure there is an error? i'm using R2016a
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!