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 CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by