update a matrix as a queue

Hi,
I would like to create a matrix of size 1000 X 1 . After each sampling period, the latest 100 elements come in and push down all the previous elements. For example:
@ t = 0 M = [a0, a1, a2,..., a998, a999]
@ t = 1 M = [a100, a101, a102,... , a1098, a1099]
Can some one recommend a good way of doing this?
Thank you

 採用された回答

Thorsten
Thorsten 2013 年 1 月 14 日

1 投票

That's easy: just put the first 900 values of your matrix after the new values:
M = [newvalues; M(1:900)];

その他の回答 (1 件)

Matt J
Matt J 2013 年 1 月 14 日

0 投票

M(1:100)=newvalues;
M=circshift(M,[0,-100]);

カテゴリ

質問済み:

SC
2013 年 1 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by