How to find the difference between non-consecutive values
6 次查看(过去 30 天)
显示 更早的评论
How do I use diff() to find the difference between a certain number of indices? Furthermore, how do I turn the datetime into seconds to find the rate of X over time.
e.g., I have a datetime array t and another array X. I want to find the difference between every two elements of X and find the rate.
t1 = datetime(2013,11,1,8,0,0);
t2 = datetime(2013,11,5,8,0,0);
t = t1:t2
X = 1:5:25
for i = 1:2:length(X)
A = diff(X(i))/diff(seconds(t(i)))
end
However, I get an empty array in A.
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!