フィルターのクリア

How to store in a separate array?

1 回表示 (過去 30 日間)
Isuru
Isuru 2014 年 3 月 29 日
回答済み: Dishant Arora 2014 年 3 月 29 日
Hi,
I have a 1x300 buffer full of timestamps called TimeBuffer. I want to find the dt (difference between each time stamp) and store this value in a separate array.
I've made a start:
i=2; dtarray = [];
while i<size(TimeBuffer,2)
dt(i)=TimeBuffer(i+1)-TimeBuffer(i);
dtarray = dt; <how to store??>
end
This doesn't give me an array of the difference between timestamps. Any help is appreciated.
Thanks

回答 (1 件)

Dishant Arora
Dishant Arora 2014 年 3 月 29 日
Your dt is itself is an array which grows in the loop as i increases, as i is the indices. And initialize dt before the loop to make it efficient.
i=1;
dt = zeros(1,length(Timebuffer)-1);
while i<length(TimeBuffer,2)
dt(i)=TimeBuffer(i+1)-TimeBuffer(i);
end
Or use diff to eliminate the loop.

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by