Info
此问题已关闭。 请重新打开它进行编辑或回答。
equality of two matrics having NaN elements
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(2 个)
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 个评论
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
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!