필터 지우기
필터 지우기

How to subtract each column of a matrix by the respective median of that column?

조회 수: 1 (최근 30일)
I want to subtract each column of a matrix by its median.
For example, for the matrix:
l=(4x3)
1 5 9
2 6 10
3 7 11
4 8 12
the median of each column is
m=
2.5000 6.5000 10.5000
Thus, matrix minus its median "l-m" equals:
-1.5 -1.5 -1.5
-0.5 -0.5 -0.5
0.5 0.5 0.5
1.5 1.5 1.5
I would appreciate if someone could tell me how to
write this command in Matlab.
Thank you
Emerson

채택된 답변

Matt Fig
Matt Fig 2011년 3월 28일
I_minus_med = bsxfun(@minus,I,median(I))
  댓글 수: 3
Zoltan
Zoltan 2012년 4월 17일
Thank Matt! A very cool function, I was looking for this for years.
Yonghun Jeong
Yonghun Jeong 2015년 7월 14일
Thank Matt Fig! I can do easily by your help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by