Quantcast
Channel: MATLAB Central Newsreader - tag:"mean"
Viewing all articles
Browse latest Browse all 26

Re: inf values for mean(___) and sum(___) functions

$
0
0
On 05/03/2015 8:52 PM, Christoph Meier wrote:
> "dpb" wrote in message <mhnvpq$t64$1@dont-email.me>...
>> On 04/27/2015 11:19 PM, Christoph Meier wrote:
...

>> > TURNO = (abs(SHVOL)./abs(SHROUT);
>> >
...

>> > mTURNO = nanmean(ans(TURNO),2);
...

I didn't notice this above; don't need (or really want) the ans() there;
you've save the variable TURNO above. ans() is the builtin for the
value returned when no explicit variable has been used; no need for it
otherwise.

>> As an aside, why the abs(); aren't both volume and turnover just
>> quantities?
...

> I used abs(), as I wanted to exclude NANs. ...

Well, it is absolutely ineffective for that purpose as

 >> abs(nan)
ans =
    NaN
 >>

(which, ussage, btw, also illustrates where ans() exists.)

If there is a possibility there's a NaN in the two and don't want to
include them, then you need to return the common locations where there
are no NaN in either vector of inputs.

idx=!(isnan(SHVOL) | isnan(SHROUT)); % NOT NaN in 'x' OR 'y'
TURNO=SHVOL(idx)./SHROUT(idx); % result for those locations only

Now if you have Inf as a result then either one (or more) of SHVOL-->inf
or SHROUT-->0 for finite SHVOL.

doc isnan
doc isfinite % and friends...

--

Viewing all articles
Browse latest Browse all 26

Trending Articles