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:
))>((0
end
Here, A>0 creates a logical matrix of the same shape as A, in which elements greater than zero turn into true, and those less than zero turn into false. )>(0 produces an array of all the positive elements in A, and the built-in function sum computes their sum.
(a) Write a function named problem 2a that takes in two arrays A and B as input, and returns one output: the sum (collectively) of all prime elements in A and all odd elements in B.(hint: look up the function isprime)
(b) Write a function named problem 2b 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.
 matlab For example, consider the following function, which computes the sum

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