Substituting NaN values of one matrix to another?

4 ビュー (過去 30 日間)
Nicole West
Nicole West 2012 年 11 月 26 日
Hello, I have two matrices of equal dimensions. In one matrix I have set a threshold value, over which the cells are set to NaN. If possible, I would like to set the same i,j cells of the second matrix to NaN as well, essentially using the first matrix as a "mask." Is this possible? Any advice you can provide would be appreciated! Thanks, Nikki

採用された回答

James Tursa
James Tursa 2012 年 11 月 27 日
a = first matrix with NaN values
b(isnan(a)) = nan;

その他の回答 (1 件)

Thomas
Thomas 2012 年 11 月 26 日
Some thing like this;
a=[1 2 3;4 1 0 ;1 3 8]
b=[4 5 6; 7 8 9; 1 2 3]
b(a>3)=NaN; % anything above 3 in a becomes NaN in b
a(a>3)=NaN; % anything above 3 in a becomes NaN in a
a
b

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by