set the values to nan

263 Ansichten (letzte 30 Tage)
Hana
Hana am 11 Dez. 2014
Beantwortet: Yu Jiang am 11 Dez. 2014
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.

Akzeptierte Antwort

Yu Jiang
Yu Jiang am 11 Dez. 2014
>> B1 = tb1;
>> B1(A1==0) = NaN;

Weitere Antworten (1)

Giorgos Papakonstantinou
Giorgos Papakonstantinou am 11 Dez. 2014
Bearbeitet: Giorgos Papakonstantinou am 11 Dez. 2014
Try this Hana
B1 = tb1;
B1(A1==0) = NaN;

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by