Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 MATLAB 中实现嵌套 for 循环,第一个循环应该从 3 运行到 n,在这个循环内,第二个 for 循环应该运行 1:5。我的问题是我想取 5 个数字的平均值,但要取一个移动平均线。所以我应该从第一行的元素 1 到 5 的平均值开始,第二行的元素 2 到 6 的平均值,第三行的元素 3 到 7 的平均值。
请帮我解决这个问题。
提前致谢
我的假设是,您正在寻找这样的东西......没有嵌套的 for-loop:
for i = 3:n some_average(i) = mean(some_data_matrix(i, i:(i+4))); end
不过,您的问题需要进一步澄清。