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

here are the inputs and outputs

2 个评论
David K.
2019-8-6
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);
Patrick Jenks
2019-8-6
Thank you!
I thought the magnitiude was off, but I was probably mistaken. I appreciate the help!
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Operators and Elementary Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!