Question: matlab For example, consider the following function, which computes the sum of all positive elements of a matrix: ) ) > ( ( 0 end
matlab For example, consider the following function, which computes the sum of all positive elements of a matrix:
end
Here, creates a logical matrix of the same shape as in which elements greater than zero turn into true, and those less than zero turn into false. produces an array of all the positive elements in and the builtin function sum computes their sum.
a Write a function named problem a that takes in two arrays A and as input, and returns one output: the sum collectively of all prime elements in A and all odd elements in Bhint: look up the function isprime
b Write a function named problem that takes in one array A as input, and returns a modified version of A where all positive elements have boen replacid by their square root.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
