如何在MATLAB中创建循环缓冲区以正确顺序进行连续测量 [英] How to create a circular buffer in MATLAB for continuous measurements in the correct order

查看:341
本文介绍了如何在MATLAB中创建循环缓冲区以正确顺序进行连续测量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了以下内容:如何创建是MATLAB中用于连续测量的缓冲矩阵吗?,问题.我想知道是否有可能按顺序而不是按问题中的顺序存储值,而无需在每次迭代后求助于fliplr(从左向右翻转)?

I read the: How to create a buffer matrix in MATLAB for continuous measurements?, question. I wanted to know if its possible to store values in sequence instead of in reverse as in the question, without resorting to fliplr (flip left to right) after each iteration?

推荐答案

从前到后:

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

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

circBuff = 1000 999 998 997 996 995 994 993 992 991

这篇关于如何在MATLAB中创建循环缓冲区以正确顺序进行连续测量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆