Prev: ctrl+c
Next: Fit problem
From: Jos (10584) on 1 Jul 2010 05:57 "Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <i0hm71$8s7$1(a)fred.mathworks.com>... > "Antonio Trujillo-Ortiz" <atrujo(a)uabc.edu.mx> wrote in message <i0hbsv$ker$1(a)fred.mathworks.com>... > > Hi Joerg, > > > > Thanks for your answer. I'm sorry. In my initial post in the resulting matrix R, I miss to type the 3rd row. So, it must be: > > > > R=[6 0 3;7 2 6;5 1 2;6 1 5]; > > > > As you can see. In the initial matrix A with NaN's, > > > > A = [NaN 0 3;7 2 6;5 1 2;NaN NaN 5]; > > > > I have the columns 1 & 2 with them. With the two corresponding nanmeans=6,1. Which I need to replace with its corresponding NaN's elements. > > > > I'm awaiting for any hint. > > > > Thx. > > > A = [NaN 0 3;7 2 6;5 1 2;NaN NaN 5]; > > % column nanmeans (I suppose you have the Stats TB) > colMeans = nanmean(A); > % Find the position of nans > [row,col] = find(isnan(A)); > % Replace with means > A(isnan(A)) = colMeans(col); > > Oleg Alternatively: A = [NaN 0 3;7 2 6;5 1 2;NaN NaN 5]; B = repmat(nanmean(A,1),size(A,1),1) q = ~isnan(A) B() = A(q) Jos
|
Pages: 1 Prev: ctrl+c Next: Fit problem |