Can anyone solve this? Find the shortest distance between the plane 3*x1+4*x2+x3=1 and the point (-1,1,1). (optimization problem?)

7 visualizzazioni (ultimi 30 giorni)
Find the shortest distance between the plane 3*x1+4*x2+x3=1 and the point (-1,1,1)

Risposte (2)

Bruno Luong
Bruno Luong il 16 Dic 2018
Modificato: Bruno Luong il 16 Dic 2018
n = [3;4;1];
d = abs((n'*[-1;1;1]-1)/sqrt(n'*n))
gives:
d =
0.1961
  2 Commenti
Busra Tabak
Busra Tabak il 16 Dic 2018
thank you, correct answer but this is not optimization solution. I tried this code
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

Accedi per commentare.


Alan Weiss
Alan Weiss il 17 Dic 2018
If you want to use an optimization technique, see Shortest Distance to a Plane.
Alan Weiss
MATLAB mathematical toolbox documentation

Categorie

Scopri di più su Mathematics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by