Finding an unknown vector from three known vectors

조회 수: 2 (최근 30일)
Aliff Firdaus Suhaimi
Aliff Firdaus Suhaimi 2021년 1월 4일
댓글: Aliff Firdaus Suhaimi 2021년 1월 5일
Hi, I have some problem in writing the code. Let say I have vector A = [125 350 -80], B=[-115 350 -80], D=[-15 530 545] and I need to determine the positon of vector C. The lengths/magnitudes are given which are CA=300, CB=300, CD=650. How do I determine the value for C1 C2 C3?

채택된 답변

David Hill
David Hill 2021년 1월 4일
syms x y z;
C=[x,y,z];
A = [125 350 -80];
B = [-115 350 -80];
D = [-15 530 545];
eq1=norm(A-C)==300;
eq2=norm(B-C)==300;
eq3=norm(D-C)==650;
eqns=[eq1,eq2,eq3];
c=vpasolve(eqns,[x,y,z]);
  댓글 수: 1
Aliff Firdaus Suhaimi
Aliff Firdaus Suhaimi 2021년 1월 5일
Thanks for your help! I'm doing it wrong before this. Since vpasolve only give one solution I add initial values so that it will give me the answer that I want.
Right now I'm trying to make for loop as the value of CD is decreasing with increment -5 until 550. What I did below give me the same result for every looping. I can't seem to figure out where is the wrong part.
clear
close all
clc
syms x y z;
C=[x,y,z];
A = [125 350 -80];
B = [-115 350 -80];
D = [-15 530 545];
eq1=norm(A-C)==300;
eq2=norm(B-C)==300;
eq3=norm(D-C)==650;
eqns=[eq1,eq2,eq3];
for n=1:1
C=vpasolve(eqns,[x,y,z],[5;500;-90]);
end
for eq3=650:-10:550
ansx=['Cx',C.x];
disp (ansx)
ansy=['Cy',C.y];
disp (ansy)
ansz=['Cz',C.z];
disp (ansz)
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by