Question: Write a script without using loops that for a given vector will count how many of its elements are positive ( nP ) , how

Write a script without using loops that for a given vector will count how many of its elements are positive (nP), how many are negative (nN) and how many are equal to zero (nZ). Use logical indexing.
For instance,
if the vector is [2-5083-9], the answer would be nP=3, nN=2 and nZ=1,
if the vector is [-9], the answer would be nP=0, nN=1 and nZ=0.
Test your code for vector [106-94020-1300-4-62].

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!