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 one

Subject: beginner one

From: Pink Panther

Date: 6 Jul, 2010 14:52:04

Message: 1 of 2

hi, sorry for this basic one :
given a vector, say
A = [ -4 3 -5 2 1 3 0 0 0 0 0]
I'd like to calculate the % of positive numbers, excluding the 0, so in the present case the answer would be 4 / 6 (as there are 4 positive numbers, 2 negative, and 5 = 0). how can I get that ? many thanks in advance

Subject: beginner one

From: Andy

Date: 6 Jul, 2010 14:59:06

Message: 2 of 2

"Pink Panther " <huguesrialan@gmail.com> wrote in message <i0vfuk$qpu$1@fred.mathworks.com>...
> hi, sorry for this basic one :
> given a vector, say
> A = [ -4 3 -5 2 1 3 0 0 0 0 0]
> I'd like to calculate the % of positive numbers, excluding the 0, so in the present case the answer would be 4 / 6 (as there are 4 positive numbers, 2 negative, and 5 = 0). how can I get that ? many thanks in advance

A = [ -4 3 -5 2 1 3 0 0 0 0 0];
pr = nnz(A>0)/nnz(A);

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