Differences between adjacent elements of an array (diff(A))

I am trying to either run a script with diff(A), or create a for loop that essentially does the same thing. My outputs for both are the same, but still dont give correct values.
Here is the script
script.PNG
here are the inputs and outputs
inputs.JPG

댓글 수: 2

Are you showing the theoretical correct outputs? Because they look right to me. Do you wish them to be moved up 1?
Also, to find the difference you can do it without a loop:
diffhours = hourOfRecord(2:end)-hourOfRecord(1:end-1);
Thank you!
I thought the magnitiude was off, but I was probably mistaken. I appreciate the help!

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

질문:

2019년 8월 6일

댓글:

2019년 8월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by