Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
beginner question

Subject: beginner question

From: Pink Panther

Date: 21 Jun, 2010 17:00:22

Message: 1 of 5

hi, sorry for this beginner question :
in a matrix I have one line with 'results', I'd like to calculate the ratio of results > 0 to all results. is there a simple/elegant way of doing that ?
thanks

Subject: beginner question

From: someone

Date: 21 Jun, 2010 17:16:23

Message: 2 of 5

"Pink Panther " <huguesrialan@gmail.com> wrote in message <hvo5r6$o05$1@fred.mathworks.com>...
> hi, sorry for this beginner question :
> in a matrix I have one line with 'results', I'd like to calculate the ratio of results > 0 to all results. is there a simple/elegant way of doing that ?
> thanks

Not sure what you wnat to do.
Can you provide a specific example?
What does "one line with 'results'" mean?

Subject: beginner question

From: Pink Panther

Date: 21 Jun, 2010 17:44:10

Message: 3 of 5

"someone" <someone@somewhere.net> wrote in message <hvo6p7$o14$1@fred.mathworks.com>...
> "Pink Panther " <huguesrialan@gmail.com> wrote in message <hvo5r6$o05$1@fred.mathworks.com>...
> > hi, sorry for this beginner question :
> > in a matrix I have one line with 'results', I'd like to calculate the ratio of results > 0 to all results. is there a simple/elegant way of doing that ?
> > thanks
>
> Not sure what you wnat to do.
> Can you provide a specific example?
> What does "one line with 'results'" mean?

the word 'result' might be misleading. just consider we have a one line vector, with numbers positive and negative, I'd like to calculate the proportion of numbers >0 to those <0.
so for a serie like [6 3 -2 0 0 0] the answer would be 2 / 1 = 2

Subject: beginner question

From: Bruce Bowler

Date: 21 Jun, 2010 18:03:52

Message: 4 of 5

On Mon, 21 Jun 2010 17:44:10 +0000, Pink Panther set fingers to keyboard
and typed:

> "someone" <someone@somewhere.net> wrote in message
> <hvo6p7$o14$1@fred.mathworks.com>...
>> "Pink Panther " <huguesrialan@gmail.com> wrote in message
>> <hvo5r6$o05$1@fred.mathworks.com>...
>> > hi, sorry for this beginner question : in a matrix I have one line
>> > with 'results', I'd like to calculate the ratio of results > 0 to all
>> > results. is there a simple/elegant way of doing that ? thanks
>>
>> Not sure what you wnat to do.
>> Can you provide a specific example?
>> What does "one line with 'results'" mean?
>
> the word 'result' might be misleading. just consider we have a one line
> vector, with numbers positive and negative, I'd like to calculate the
> proportion of numbers >0 to those <0. so for a serie like [6 3 -2 0 0 0]
> the answer would be 2 / 1 = 2

a = [6 3 -2 0 0 0];
sum(a>0)/sum(a<0)



--
+-------------------+---------------------------------------------------+
Bruce Bowler | After two years in Washington, I often long for
1.207.633.9610 | the realism and sincerity of Hollywood.
bbowler@bigelow.org | - Fred Thompson
+-------------------+---------------------------------------------------+

Subject: beginner question

From: Bruce Bowler

Date: 21 Jun, 2010 18:08:34

Message: 5 of 5

On Mon, 21 Jun 2010 18:03:52 +0000, Bruce Bowler set fingers to keyboard
and typed:

> On Mon, 21 Jun 2010 17:44:10 +0000, Pink Panther set fingers to
> keyboard and typed:
>
>> "someone" <someone@somewhere.net> wrote in message
>> <hvo6p7$o14$1@fred.mathworks.com>...
>>> "Pink Panther " <huguesrialan@gmail.com> wrote in message
>>> <hvo5r6$o05$1@fred.mathworks.com>...
>>> > hi, sorry for this beginner question : in a matrix I have one line
>>> > with 'results', I'd like to calculate the ratio of results > 0 to
>>> > all results. is there a simple/elegant way of doing that ? thanks
>>>
>>> Not sure what you wnat to do.
>>> Can you provide a specific example?
>>> What does "one line with 'results'" mean?
>>
>> the word 'result' might be misleading. just consider we have a one line
>> vector, with numbers positive and negative, I'd like to calculate the
>> proportion of numbers >0 to those <0. so for a serie like [6 3 -2 0 0
>> 0] the answer would be 2 / 1 = 2
>
> a = [6 3 -2 0 0 0];
> sum(a>0)/sum(a<0)

PS. Don't forget to check that there *are* elements < 0 before you try
this :-)

--
+-------------------+---------------------------------------------------+
Bruce Bowler | Self-respect is the secure feeling that no one, as
1.207.633.9610 | yet, is suspicious.
bbowler@bigelow.org | - H. L. Mencken
+-------------------+---------------------------------------------------+

Tags for this Thread

No tags are associated with this thread.

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.

Contact us