Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function that, given any input vector , returns the number of times non-negative values appear in the vector. You must use looping and

Write a function that, given any input vector, returns the number of times non-negative values appear in the vector. You must use looping and branching (examining each element) to implement this function.

Again, the input calling argument is a 1D array (i.e., a vector).

For example, given the input [1;-1;1] the result is 2

For example, given the input [1,2,-3,4,-3,-4,3,-2,3,0,2] the result is 7 For example, given the input [0,1,2] the result is 3 For example, given the input [-5,-3,-1] the result is 0

Note that the result is returned by the function, not printed by the function.

Remember that the input calling argument's values come from outside of the function and are not to be set within the function.

For extra credit, provide (as a comment) the one-line Matlab expression that could calculate the above.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

What is CVP analysis? How is it useful to managers?

Answered: 1 week ago

Question

LO4 List options for development needs analyses.

Answered: 1 week ago