Thread Subject: How to do this in the vector form?

Subject: How to do this in the vector form?

From: Mohammad Monfared

Date: 21 Jan, 2009 16:23:02

Message: 1 of 6

Hi everybody!

I have a 12 by 200 matrix, say A. I'd like to compute the mean values of each row for non-zero elements. I know some ways to to this job but not the vector form solution. Is there any vector-form answer?

thanks,
Reza.

Subject: How to do this in the vector form?

From: Matt

Date: 21 Jan, 2009 16:37:02

Message: 2 of 6

"Mohammad Monfared" <gohardoust@gmail.com> wrote in message <gl7i56$pei$1@fred.mathworks.com>...
> Hi everybody!
>
> I have a 12 by 200 matrix, say A. I'd like to compute the mean values of each row for non-zero elements. I know some ways to to this job but not the vector form solution. Is there any vector-form answer?
>
> thanks,
> Reza.

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

Subject: How to do this in the vector form?

From: Mohammad Monfared

Date: 21 Jan, 2009 17:04:01

Message: 3 of 6

"Matt " <mjacobson.removethis@xorantech.com> wrote in message <gl7ive$nrj$1@fred.mathworks.com>...
> "Mohammad Monfared" <gohardoust@gmail.com> wrote in message <gl7i56$pei$1@fred.mathworks.com>...
> > Hi everybody!
> >
> > I have a 12 by 200 matrix, say A. I'd like to compute the mean values of each row for non-zero elements. I know some ways to to this job but not the vector form solution. Is there any vector-form answer?
> >
> > thanks,
> > Reza.
>
> sum(A,2)./sum(A~=0,2)
>

oh! Great and simple. so thanks!
Is it possible to use the 'trimmean' function in vector form or the 'sort' should be employed?

Reza.

Subject: How to do this in the vector form?

From: Matt

Date: 21 Jan, 2009 17:13:02

Message: 4 of 6

"Mohammad Monfared" <gohardoust@gmail.com> wrote in message <gl7ki1$fhs$1@fred.mathworks.com>...
> "Matt " <mjacobson.removethis@xorantech.com> wrote in message <gl7ive$nrj$1@fred.mathworks.com>...
> > "Mohammad Monfared" <gohardoust@gmail.com> wrote in message <gl7i56$pei$1@fred.mathworks.com>...
> > > Hi everybody!
> > >
> > > I have a 12 by 200 matrix, say A. I'd like to compute the mean values of each row for non-zero elements. I know some ways to to this job but not the vector form solution. Is there any vector-form answer?
> > >
> > > thanks,
> > > Reza.
> >
> > sum(A,2)./sum(A~=0,2)
> >
>
> oh! Great and simple. so thanks!
> Is it possible to use the 'trimmean' function in vector form or the 'sort' should be employed?
>
> Reza.


I'm not familiar with 'trimmean' nor with its relation to 'sort'.

Subject: How to do this in the vector form?

From: Walter Roberson

Date: 21 Jan, 2009 18:40:23

Message: 5 of 6

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)?

Subject: How to do this in the vector form?

From: Mohammad Monfared

Date: 21 Jan, 2009 19:41:02

Message: 6 of 6

Walter Roberson <roberson@hushmail.com> wrote in message <a_Jdl.18329$Ew6.17698@newsfe22.iad>...
> 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)?

Yes you are right!
I was thinking a way using 'trimmean' function in a vector form. It seems I should write a function and check for occasions.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com