How to change time intervals to time elapsed
1 回表示 (過去 30 日間)
古いコメントを表示
I have time data in a column vector which was measured in intervals of time meaning I can't plot this against distance to get a velocity graph.
How do I create a new column vector with the total time elapsed up to each point? (e.g. 1,2,1,1,3 to 1,3,4,5,8)
Thanks
0 件のコメント
採用された回答
SHIVAM KUMAR
2021 年 2 月 2 日
You can do this simply using a loop
a=[1 2 1 1 3]
sum=0;
result=zeros(1,length(a));
for i=1:length(a)
sum=sum+a(i);
result(i)=sum;
end
It this is fine accept the answer.
3 件のコメント
Steven Lord
2021 年 2 月 2 日
The cumsum function also works with a duration array, if you want to make it clear that your time data does represent time.
m = minutes(randi([0 9], 1, 7)) + seconds(randi([0 59], 1, 7));
m.Format = 'mm:ss'
n = cumsum(m)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!