I have code that integrates velocity to get position. I want to know when the position of projectile = 0 (ie time of flight), but there is no value in position vector where position = 0 at time of flight as position is measured periodically.
i.e How can I calculate time of flat for a projectile (intercept of position=0) when height of projectile is measured periodically?
index.jpg
This is the code I have to calculate position:
for t = 1:1:1500
v = cumtrapz(time,acceleration)
position = cumtrapz(time,v)
if t <= (60/dt)
acceleration(t) = (Fup-Fdown) /mass
else
acceleration(t) = (-Fdown) /mass;
end
time(t) = t*dt;
end

댓글 수: 1

Jan
Jan 2018년 12월 3일
편집: Jan 2018년 12월 3일
@afrhy: It is impolite to delete the question after someone has spent the time to post an answer. Please stop this. When you participate in the forum, the terms of use involve, that you are willing to share your questions with the community.

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

답변 (1개)

Star Strider
Star Strider 2018년 11월 21일

0 개 추천

I cannot run your code.
You can get the index of the first position that is negative using the find function:
negpos - find(position <= 0, '1, 'first');
The time will then be either:
tfinal = t(negpos)
or
tfinal = time(negpos)
depending on what you want.

카테고리

도움말 센터 및 File Exchange에서 Brakes and Detents에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2018년 11월 21일

편집:

Jan
2018년 12월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by