Prev: RF PUSH-PULL AMPLIFIER SIMULATION
Next: infinite loop
From: someone on 16 Jul 2010 09:50 "antonio ferreira" <edgar.acferreira(a)gmail.com> wrote in message <i1pndo$4vm$1(a)fred.mathworks.com>... > "Andy " <myfakeemailaddress(a)gmail.com> wrote in message <i1pm4h$ci2$1(a)fred.mathworks.com>... > > Whoops. I misread how you wanted to handle NaNs. You should use nanmean, as us suggested. > > I tried to use the function nanmean for a simple example but it´s not working correctly. > I am receiving a message saying:Undefined function or method 'nanmean' for input arguments of type 'double'. > The example: > A=[1 2 3;4 5 NaN;7 8 NaN] > B=nanmean(A) > > Any suggestions?regards As us asked, do you own the Statistics Toolbox?
From: antonio ferreira on 16 Jul 2010 10:00 "someone" <someone(a)somewhere.net> wrote in message <i1po2g$g7h$1(a)fred.mathworks.com>... > "antonio ferreira" <edgar.acferreira(a)gmail.com> wrote in message <i1pndo$4vm$1(a)fred.mathworks.com>... > > "Andy " <myfakeemailaddress(a)gmail.com> wrote in message <i1pm4h$ci2$1(a)fred.mathworks.com>... > > > Whoops. I misread how you wanted to handle NaNs. You should use nanmean, as us suggested. > > > > I tried to use the function nanmean for a simple example but it´s not working correctly. > > I am receiving a message saying:Undefined function or method 'nanmean' for input arguments of type 'double'. > > The example: > > A=[1 2 3;4 5 NaN;7 8 NaN] > > B=nanmean(A) > > > > Any suggestions?regards > > As us asked, do you own the Statistics Toolbox? No.
From: Andy on 16 Jul 2010 10:14 % In that case: a=rand(100,100); % sample data a(a<0.3) = NaN; % insert some NaNs for ix=1:100 b(ix) = mean(a(ix,~isnan(a(ix,:)))); end
From: dpb on 16 Jul 2010 10:17 antonio ferreira wrote: > "Andy " <myfakeemailaddress(a)gmail.com> wrote in message > <i1pm4h$ci2$1(a)fred.mathworks.com>... >> Whoops. I misread how you wanted to handle NaNs. You should use >> nanmean, as us suggested. > > I tried to use the function nanmean for a simple example but it´s not > working correctly. > I am receiving a message saying:Undefined function or method 'nanmean' > for input arguments of type 'double'. > The example: > A=[1 2 3;4 5 NaN;7 8 NaN] > B=nanmean(A) > > Any suggestions?regards which nanmean % looks like don't have the stats toolbox if not, sotoo (untested) Assume x is data matrix... ncol = size(x,2); mn = zeros(1,ncol); % preallocate for ix = 1:ncol n = length(~isnan(x(:,ix)); % no non-NaNs / column mn(ix) =sum(x(~isnan(x(:,ix)),ix))/n; end Salt to suit... --
From: Travis Knepp on 16 Jul 2010 16:51
dpb <none(a)non.net> wrote in message <i1ppqr$i73$1(a)news.eternal-september.org>... > antonio ferreira wrote: > > "Andy " <myfakeemailaddress(a)gmail.com> wrote in message > > <i1pm4h$ci2$1(a)fred.mathworks.com>... > >> Whoops. I misread how you wanted to handle NaNs. You should use > >> nanmean, as us suggested. > > > > I tried to use the function nanmean for a simple example but it´s not > > working correctly. > > I am receiving a message saying:Undefined function or method 'nanmean' > > for input arguments of type 'double'. > > The example: > > A=[1 2 3;4 5 NaN;7 8 NaN] > > B=nanmean(A) > > > > Any suggestions?regards > > which nanmean % looks like don't have the stats toolbox > > if not, sotoo (untested) > > Assume x is data matrix... > > ncol = size(x,2); > mn = zeros(1,ncol); % preallocate > for ix = 1:ncol > n = length(~isnan(x(:,ix)); % no non-NaNs / column > mn(ix) =sum(x(~isnan(x(:,ix)),ix))/n; > end > > Salt to suit... > > -- Could download the NaNsuite as posted by Jan Gläscher. http://www.mathworks.com/matlabcentral/fileexchange/6837 |