Dynamics Problem using two moving object
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
BlkHoleSun
am 27 Okt. 2017
Kommentiert: BlkHoleSun
am 30 Okt. 2017
I've been having problems solving this equation in MATLAB. Solving on paper is more intuitive to me and I'm struggling in making the language jump. So far, here is my code:
pA = [0 14]; %position of ship A at start
pB = [-25 0]; %position of ship B at start
vA = [0 -7]; %velocity of ship A at start
vB = [16 0]; %velocity of ship B at start
for t=1:4;
dA=(pA+vA*t) %position of A based on time
dB=(pB+vB*t) %position of B based on time
end
I can't seems to figure out how to get the positions of each of the ships in relation to each other. Once I do that, I was attempting to use the zeros function to solve for the 8 mile visibility. couldn't get it to work. Thanks for your help!
0 Kommentare
Akzeptierte Antwort
Birdman
am 27 Okt. 2017
Bearbeitet: Birdman
am 27 Okt. 2017
You can find position of A with repsect to B by the following:
pAwrtB=dA-dB;%position of A with repsect to B
vice versa:
pBwrtA=dB-dA;%position of B with repsect to A
Because imagine every time we spot our position on the x-y coordinate axis, we actually reference to the origin and to this
dOurPosition - [0 0]
But in this situation, relative positions are found just as above. Change the for loop like this:
for t=1:4
dA=pA+vA*t;
dB=pB+vB*t;
pBwrtA=dB-dA;%position of B with repsect to A
pAwrtB=dA-dB;%position of A with repsect to B
end
4 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!