MATLAB: Comparing matices that contain numbers and NaNs

cell

I have 2 cell matrices R and W and I want to check if they contain the same elements. Specifically, I want to compare R which is obtained from
[N,T,R] = xlsread( filename); %
with another matrix W.Both matrices are cell matrices and can also contain NaN entries.
My goal: If my calculations are correct then
kk=W(7 ,3:end); should contain the same elements with
zz1=R(7,3:end);
or zz2=R(8,3:end);
So to test this I do something like
if zz==xx1 | zz== xx2
'OK' else 'Not OK' EndThe problem is that
zz==xx1
??? Undefined function or method 'eq' for input arguments of type 'cell'.
So I use cell2mat(zz)==cell2mat(xx1) and it works.
But if zz and xx1 contain NaN then for some reason I cannot use the cell2mat() approach
I am looking for a general approach that will enable me to do that comparison whether I have NaN and numbers or only numbers’
thanks

Best Answer

variant of comparison cell arrays (edit)
A = {...
[84] [ 93] [ 109]
[99] [NaN] [ 62]
[29] [123] 'dgdgdg'};
B = {...
[84] [ 93] [ 109]
[99] [NaN] [ 62]
[29] [123] 'dgdgdg'};
A1=A;
B1=B;
A1(cellfun(@(x)all(isnan(x)),A)) = {0};
B1(cellfun(@(x)all(isnan(x)),B)) = {0};
out = isequal(A1,B1);