set the values to nan

385 ビュー (過去 30 日間)
Hana
Hana 2014 年 12 月 11 日
回答済み: Yu Jiang 2014 年 12 月 11 日
tb1=[1 2 3 ; 4 5 6 ; 7 8 9]; A1=[0 0 1;1 1 1;0 1 1];
I need to create a new array B1=[nan nan 3;4 5 6;nan 8 9]
when A1=0, then B1 should be nan otherwise it should take the values in tb1.

採用された回答

Yu Jiang
Yu Jiang 2014 年 12 月 11 日
>> B1 = tb1;
>> B1(A1==0) = NaN;

その他の回答 (1 件)

Giorgos Papakonstantinou
Giorgos Papakonstantinou 2014 年 12 月 11 日
編集済み: Giorgos Papakonstantinou 2014 年 12 月 11 日
Try this Hana
B1 = tb1;
B1(A1==0) = NaN;

カテゴリ

Help Center および 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