如何在m的窗口中选择序列的n个元素? (matlab) [英] How do I select n elements of a sequence in windows of m ? (matlab)

查看:190
本文介绍了如何在m的窗口中选择序列的n个元素? (matlab)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速MATLAB问题. 在"m"个窗口中选择一定数量的元素"n"的最佳/最有效方法是什么.换句话说,我要选择序列的前50个元素,然后选择元素10-60,然后选择元素20-70. 现在,我的序列是矢量格式(但是可以很容易地更改).

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 first 50 elements of a sequence, then elements 10-60, then elements 20-70 ect. Right now, my sequence is in vector format(but this can easily be changed).

我正在处理的序列太长,无法存储在我的RAM中.我需要能够创建窗口,然后调用要分析/执行另一个命令的窗口.

The sequences that I am dealing with are too long to be stored in my RAM. I need to be able to create the windows, and then call upon the window that I want to analyze/preform another command on.

推荐答案

您是否有足够的RAM可以在内存中存储50×nWindow数组?在这种情况下,您可以一次性生成窗口,然后将处理应用于每一列

Do you have enough RAM to store a 50-by-nWindow array in memory? In that case, you can generate your windows in one go, and then apply your processing on each column

%# idxMatrix has 1:50 in first col, 11:60 in second col etc
idxMatrix = bsxfun(@plus,(1:50)',0:10:length(yourVector)-50); %'#

%# reshapedData is a 50-by-numberOfWindows array
reshapedData = yourVector(idxMatrix);

%# now you can do processing on each column, e.g.
maximumOfEachWindow = max(reshapedData,[],1);

这篇关于如何在m的窗口中选择序列的n个元素? (matlab)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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