MATLAB: Replacing NaNs with zero in a matrix within a cell array.

cell arraysreplacing nans

How to replace NaNs with 0 in a cell array that has the following anatomy 13×1 cell, Each cell is of size 63×63[double]. the cell name is 'a'.
Any help would be appreciated, Thank you in advance.

Best Answer

a = cellfun(@(M) subsasgn(M, substruct('()', {isnan(M)}), 0), a, 'uniform', 0);
No loop needed... just ugly code.