How do I select n elements of a sequence in windows of m ? (matlab)

前端 未结 5 1126
温柔的废话
温柔的废话 2021-01-19 10:47

Quick MATLAB question. What would be the best/most efficient way to select a certain number of elements, \'n\' in windows of \'m\'. In other words, I want to select the fir

5条回答
  •  佛祖请我去吃肉
    2021-01-19 11:18

    To complement Kerrek's answer: if you want to do it in a loop, you can use something like

    n = 50
    m = 10;
    for i=1:m:length(v)
        w = v(i:i+n);
        % Do something with w
    end
    

提交回复
热议问题