Question: Write a function called RoundZero() that iterates through each value in a matrix and rounds positive numbers to the nearest integer, and sets negative numbers

Write a function called "RoundZero()" that iterates through each value in a matrix and rounds positive numbers to the nearest integer, and sets negative numbers equal to zero.

Your function takes a single input variable:

  • M - a matrix of floating point double numbers.

Your function has three outputs:

  • Mout - the matrix with rounded and zeroed values
  • nr - the number of positive elements rounded.
  • n0 - the number of negative elements set to zero, or originally zero.

Step by Step Solution

3.31 Rating (148 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres an implementation of the RoundZero function in Python import numpy as ... View full answer

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 Mathematics Questions!