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

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 件のコメント

Emerson De Souza
Emerson De Souza 2011 年 3 月 28 日
Thank you Matt Fig
your instruction
was very helpful.
I wish you a nice day
Emerson
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 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by