필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

equality of two matrics having NaN elements

조회 수: 1 (최근 30일)
som
som 2012년 1월 17일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi All I have two matrices A and B having some NaN elements. I want to investigate the equality of these matrices. How can I do it? For example: A=[1 2 3; 4 5 NaN] , B=[1 2 3; NaN 5 NaN ] Thanks for your guidance.

답변 (2개)

Andrei Bobrov
Andrei Bobrov 2012년 1월 17일
out = A == B
OR
out = ismember(A,B)
result:
out =
1 1 1
0 1 0
in MATLAB:
NaN ~= NaN
variant
A(isnan(A)) = 0;
B(isnan(B)) = 0;
out = A == B
out =
1 1 1
0 1 1
  댓글 수: 1
som
som 2012년 1월 17일
thanks for your help

Julian
Julian 2012년 1월 17일
Consider the following
>> A=[1 2 3; 4 5 NaN] , B=[1 2 3; NaN 5 NaN ]
A =
1 2 3
4 5 NaN
B =
1 2 3
NaN 5 NaN
>> a=A
a =
1 2 3
4 5 NaN
>> a(isnan(B))=NaN
a =
1 2 3
NaN 5 NaN
>> isequalwithequalnans(a,B)
ans =
1

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by