How to calculate velocity of length change and acceleration of it?

조회 수: 3 (최근 30일)
lisa Liang
lisa Liang 2020년 7월 30일
답변: Cris LaPierre 2020년 7월 30일
Hello everyone,
I am trying to calculate velocity and acceleration of a length change out of the 'AddDist' matrix. I am thinking of using V=(length 2 - length 1)/time for velocity (which should give me a vector not scalar?) and a=(V2 - V1)/time for acceleration. But I am not sure how to make MatLab have the 2nd column subtracts the 1st column, then the 3rd column subtract the 2nd column, and so on...
this is what I thought how it would work but it didn't seem to make sense in MatLab for calculating what I want. 0.002 is my time as the time gap between each rows is always 0.002s.
AddDistV = (AddDist(i+1)-AddDist(i))/(0.002)
for i = 1:size(AddDist,1)
AddDistV = (AddDist(i+1)-AddDist(i))/(1/0.002)
end
I am still trying to learn coding in MATLAB. Sorry if my question is too basic. Thank you for your help and time in advance!

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 7월 30일
Use the diff function.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by