MATLAB: How to replace NaN values with zero

MATLAB

Hello,
I have a matrix of 361*181 dimention, which contain NaN and some values.
I want to replace those NaN values with 0, I have tried A(isnan(A))=0; command but is showing error.
the error read as " Subscript indices must either be real positive integers or logicals".
can anyone help me out this?

Best Answer

Might happen that your isnan is somehow a variable maybe try the following:
clear all
A(isnan(A))=0;
%%%% an example
A=rand(3);
A([2 3],2)=NaN;
A(isnan(A))=0;
Gives:
A =
0.7339 0.8422 0.1934
0.0039 0 0.3316
0.1183 0 0.6213
Related Question