problem in using MATLAB solve functionality

1 visualización (últimos 30 días)
MingCheng Zhang
MingCheng Zhang el 22 de Oct. de 2020
Comentada: MingCheng Zhang el 26 de Oct. de 2020
Hi all,
I have three equations and three unknowns, and I want to use the matlab to solve the eqns for me, however, I realised that the matlab is not giving me a numeric solution. The output I get is just "x","y","z". The code is: (k1, k2, k3 are all known values), the data file is also attached.
syms x y z
path = cell2mat(struct2cell(load("D:\CP\map\MCTS\JPS\after_shortCut")));
k1 = ((path(2,2)-path(1,2))*(path(3,3)-path(1,3)))-((path(3,2)-path(1,2))*(path(2,3)-path(1,3)));
k2 = ((path(2,1)-path(1,1))*(path(3,3)-path(1,3)))-((path(3,1)-path(1,1))*(path(2,3)-path(1,3)));
k3 = ((path(2,1)-path(1,1))*(path(3,2)-path(1,2)))-((path(3,1)-path(1,1))*(path(2,2)-path(1,2)));
eqn1 = ((path(2,1)-path(1,1))*(x-path(1,1)))+((path(2,2)-path(1,2))*(y-path(1,2)))+((path(2,3)-path(1,3))*(z-path(1,3)));
eqn2 = k1*(x-path(1,1))+k2*(y-path(1,2))+k3*(z-path(1,3));
eqn3 = dot((path(2,:)'-path(1,:)'),(path(2,:)'-[x,y,z]'))/norm(path(2,:)'-path(1,:)')*norm(path(2,:)'-[x,y,z]')==dot((path(2,:)'-[x,y,z]'),(path(3,:)'-path(2,:)'))/norm(path(2,:)'-[x,y,z]')*norm(path(3,:)'-path(2,:)');
solve([eqn1 eqn2 eqn3],[x y z])

Respuesta aceptada

Walter Roberson
Walter Roberson el 22 de Oct. de 2020
There are no solutions for that.
You can solve the first two equations for x and y, and substitute that into the third equation. You will get something of the form
C*sqrt(A) = B/sqrt(A)
Multiply both sides by sqrt(A) to get C*A = B .
Then when you look at A you will see that it is the sum of three abs() and so must be real-valued (C is real valued), and that B has z in it that is not squared or abs() . Comparing the imaginary parts of the two sides we see that the imaginary part of the left side must be 0, and therefore the imaginary part of the right side must be zero. The B is linear in z, with no sqrt(), so the only way the imaginary parts can match is if imag(z) == 0.
So now knowing that z is real valued, we can simplify the equations -- the conj() drop out as you are dealing only with real values as their arguments. You end up with the quadratic equation
((196*z^2 - 196*z + 1949)*sqrt(38))/10 = 4*sqrt(14)*(z + 27)
so solve the quadratic equation... getting out two complex values for z. But we established earlier that z must be real-valued, not complex, because the left side must be real-valued.
We have arrived at a contradiction. Therefore no solution exists for the equations.

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by