フィルターのクリア

How to set all non-finite elements of a matrix to the minimum of the corresponding column?

5 ビュー (過去 30 日間)
dave
dave 2013 年 9 月 28 日
編集済み: Matt J 2013 年 9 月 28 日
Hi,
I have a matrix m and want to set all elements that are NaN, Inf or -Inf to the minimum of the corresponding column. For example: If m(r,c) is non-finite, it should be set to the lowest finite value of column c.
How can this be done (preferably without looping)?
Thanks...

採用された回答

Matt J
Matt J 2013 年 9 月 28 日
編集済み: Matt J 2013 年 9 月 28 日
m(~isfinite(m))=nan;
minvals=min(m,[],1);
m=bsxfun(@max,m,minvals);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by