From: Kirk on
I am running multiple iterations of a simulation process and then outputting means from all iterations with a simple call like this:

% Calculate means from Monte Carlo runs
tmax_mean=mean(tmax,2);

Every so often... one time in a thousand or so, the random combination of parameters results in NaN output. Which of course, results in NaN means.

I am looking for a MATLABish approach to calculate the mean of the variable tmax, but skip the NaNs.

Thanks in advance
From: Sean on
"Kirk" <kwythers.nospam(a)umn.edu> wrote in message <hrpiuv$1nq$1(a)fred.mathworks.com>...
> I am running multiple iterations of a simulation process and then outputting means from all iterations with a simple call like this:
>
> % Calculate means from Monte Carlo runs
> tmax_mean=mean(tmax,2);
>
> Every so often... one time in a thousand or so, the random combination of parameters results in NaN output. Which of course, results in NaN means.
>
> I am looking for a MATLABish approach to calculate the mean of the variable tmax, but skip the NaNs.
>
> Thanks in advance

>>help nanmean
From: us on
"Kirk" <kwythers.nospam(a)umn.edu> wrote in message <hrpiuv$1nq$1(a)fred.mathworks.com>...
> I am running multiple iterations of a simulation process and then outputting means from all iterations with a simple call like this:
>
> % Calculate means from Monte Carlo runs
> tmax_mean=mean(tmax,2);
>
> Every so often... one time in a thousand or so, the random combination of parameters results in NaN output. Which of course, results in NaN means.
>
> I am looking for a MATLABish approach to calculate the mean of the variable tmax, but skip the NaNs.
>
> Thanks in advance

a hint:
- if(f) you own the stats tbx

help nanmean; % <- and siblings...

us
From: Kirk on
> >>help nanmean

Wow. That's nice!