How to solve the loss of values while using the diff function ?

Hey guys , So i was given the altitude and time data for a certain incident and i was required to find velocity and acceleration . This is what a part of my code looks like :
t=0:10:250;
tv=(t(1)+t(2))/2:10:t(end);
vel=diff(c)./diff(t);
acc=diff(vel)./diff(tv);
But what do i define my time for acceleration as? is it ta = (tv(1)+tv(2))/2:10:t(end); because that did not seems to work as it would have 25 elements while i only need 24 as the acceleration variable has only 24 elements . Please help ! thanks in advance!

답변 (2개)

Stephen23
Stephen23 2017년 5월 18일
편집: Stephen23 2017년 5월 18일

1 개 추천

Use gradient instead.

댓글 수: 1

Slick. I've always zero-padded or used one of the FEX entries but this is better.

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

KSSV
KSSV 2017년 5월 18일
편집: KSSV 2017년 5월 18일
Why you are worried about size of time? You have to use time step (dt) which remains constant.
t=0:10:250;
dt = min(diff(t)) ;
% tv=(t(1)+t(2))/2:10:t(end);
vel=diff(c)./dt;
acc=diff(vel)./dt;

카테고리

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

질문:

2017년 5월 18일

댓글:

2017년 5월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by