Cut vector in set range

I have about 10 thousand vectors and I want to cut them all to special range set by my min and max . eg. have only vectors from 600 - 1000 values How to implement it in the best efficient way.

 채택된 답변

Image Analyst
Image Analyst 2013년 8월 11일

3 개 추천

Try this for each of the vectors:
minValue = 600; % Or whatever you want.
maxValue = 1000; % Or whatever you want.
indexesInRange = data > minValue & data < maxValue;
subVector = data(indexesInRange);
That will, for a vector called data, extract all the values between minValue (which you can define to be 600) and maxValue (which you can define to be 1000) into a new vector called subVector. Do this 10 thousand times for each of the vectors (most likely done in a loop).

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 11일

2 개 추천

How your vectors are stored? in a cell array? If yes
Example
v=arrayfun(@(x) randi(2000,1,100),1:10,'un',0) % your cell array
for k=1:numel(v)
out{k}=v{k}(v{k}>600 & v{k}<1000)
end

카테고리

도움말 센터File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

질문:

2013년 8월 11일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by