From: Jos (10584) on
"Joerg Buchholz" <buchholz(a)hs-bremen.de> wrote in message <i0hee7$q81$1(a)fred.mathworks.com>...


> I'm sure a Matlab expert could do that in one line of code ... ;-)

It took me a while, but here is a one-liner ... ;-)

% data
A = [NaN 0 3;7 2 6;5 1 2;NaN NaN 5]
% code
[B, B(~isnan(A))] = deal(repmat(nanmean(A,1),size(A,1),1), A(~isnan(A)))

Jos