problem in using MATLAB solve functionality
Show older comments
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])
Accepted Answer
More Answers (0)
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!