Finding distance from a projectile.

What is each line is doing on this code?
D=[1 xi(end);1 newx];
b=[yi(end);newy];
a=D\b
Distance = (-a(1)/a(2))
newx = Distance;
newy = 0;
b=[ui(end);newu];
a=D\b;
u2 = (a(1)+a(2)*Distance);
newu = u2;
b=[vi(end);newv];
a=D\b;
v2 = (a(1)+a(2)*Distance);
newv = v2;
newv = -(newv*COR);

답변 (1개)

Adam Danz
Adam Danz 2021년 3월 29일

0 개 추천

Much of this is basic Matlab syntax that should be understood in order to do almost anything in Matlab. Take some time to go through the Matlab Onramp to get caught up.
xi(end) is indexing the variable xi, retrieving is end or last value.
D=[1 xi(end);1 newx] is creating a 2x2 matrix.
a=D\b - see mldivide
The rest is either indexing, creating of matrices or arrays or basic mathematics.

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2021년 3월 29일

답변:

2021년 3월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by