필터 지우기
필터 지우기

logical indexing of a matrix with different columns

조회 수: 1 (최근 30일)
Sobhan
Sobhan 2012년 4월 23일
Dear all, This is my problem: I have a matrix of 3 columns and 100 rows. I want to find for each column the position of cells which contain values <-0.01, cells which contain values >0.01 and the other remaining cells. For each column I am only interested in the first 60 rows. I hope I am clear enough. Thanks a million for your help. Sobhan

답변 (2개)

Andrei Bobrov
Andrei Bobrov 2012년 4월 23일
lgc = youmatrix < -.1 | yourmatrix > .1;
out = arrayfun(@(ii)find(lgc(:,ii),60,'first'),1:size(yourmatrix,2),'un',0);

Daniel Shub
Daniel Shub 2012년 4월 23일
Sounds like homework to me, but I hope it is not ...
I will give you a piece, can you figure out how to make it work on only the first 60 rows, what about for -0.01<=x<=0.01.
x = randn(100, 3); % sample data
[a, b] = find(x < -0.01);
[b, a]

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by