필터 지우기
필터 지우기

How to find the median from each of the column with certain condition

조회 수: 1 (최근 30일)
Idra
Idra 2012년 10월 17일
Hi!
I have matrices like this:
x = randn(10,10);
indices = find(abs(x)>2);
x(indices) = 0;
How to find the median from each of the column for the remaining elements excluding the '0', since if I do this: y=median(x) this will appear:
y =
Columns 1 through 5
0.1897 -0.3006 0.0776 0.2009 0.4715
Columns 6 through 10
-0.0588 -0.1970 0.2665 0.2033 0.1836
The median is found by including the '0'.
Thank you!

답변 (1개)

Matt Fig
Matt Fig 2012년 10월 17일
편집: Matt Fig 2012년 10월 17일
Note that using FIND is not necessary....
x = randn(10,10);
indices = abs(x)>2; % This is a logical index.
x(indices) = nan; % Use nan instead of 0.
mn = nanmean(x)
md = nanmedian(x)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by