Path: news.mathworks.com!newsfeed-00.mathworks.com!nlpi057.nbdc.sbc.com!prodigy.net!news.glorb.com!news2.glorb.com!postnews.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!newsfe22.iad.POSTED!7564ea0f!not-for-mail
From: Walter Roberson <roberson@hushmail.com>
Organization: Canada Eat The Cookie Foundation
User-Agent: Thunderbird 2.0.0.19 (Windows/20081209)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to do this in the vector form?
References: <gl7i56$pei$1@fred.mathworks.com> <gl7ive$nrj$1@fred.mathworks.com>
In-Reply-To: <gl7ive$nrj$1@fred.mathworks.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 16
Message-ID: <a_Jdl.18329$Ew6.17698@newsfe22.iad>
NNTP-Posting-Host: 24.79.146.116
X-Complaints-To: internet.abuse@sjrb.ca
X-Trace: newsfe22.iad 1232563206 24.79.146.116 (Wed, 21 Jan 2009 18:40:06 UTC)
NNTP-Posting-Date: Wed, 21 Jan 2009 18:40:06 UTC
Date: Wed, 21 Jan 2009 12:40:23 -0600
Xref: news.mathworks.com comp.soft-sys.matlab:513001


Matt wrote:
> "Mohammad Monfared" <gohardoust@gmail.com> wrote in message <gl7i56$pei$1@fred.mathworks.com>...

>> I have a 12 by 200 matrix, say A. I'd like to compute the mean values of each row for
>> non-zero elements.

> sum(A,2)./sum(A~=0,2)

That solution leads to unexpected results if an entire row is all-zero. On the other
hand, the original poster didn't say what should be done in that case...

-- 
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?