MATLAB: Rerplace Nan by a number in a matrix

MATLABmatrixnanquaterion

a = { [5 5 5 6 ] [ Nan Nan Nan Nan]; [ 7 8 8 8 ] [1 2 3 5] }
i want to replace a{1,2} by [1 1 1 1 ]
it is possible because i had tried this function
function k = non(a) [l ,c ] = size(a); for i= 1 : l
for j =1 : c
if a{i,j} == [ NaN NaN NaN NaN ]
k{i,j} = [ 1 1 1 1]
else
k{i,j} = a{i,j} ;
end
end
end
end
but it dosen't works i need your help pleeease

Best Answer

Use isnan and logical indexing.