我读了:How to create a buffer matrix in MATLAB for continuous measurements?,问题。我想知道是否有可能按顺序而不是按问题中的顺序存储值,而无需在每次迭代后求助于fliplr(从左向右翻转)?
最佳答案
从前到后:
buffSize = 10;
circBuff = nan(1,buffSize);
for newest = 1:1000;
circBuff = [circBuff(2:end) newest]
end
circBuff =
991 992 993 994 995 996 997 998 999 1000
回到前面:
buffSize = 10;
circBuff = nan(1,buffSize);
for newest = 1:1000;
circBuff = [newest circBuff(1:end-1)]
end
circBuff =
1000 999 998 997 996 995 994 993 992 991
关于matlab - 如何在MATLAB中创建循环缓冲区以正确顺序进行连续测量,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1486446/