Question: Consider the following two functions written in Matlab: function [n] = countval( v,x ) n= sum(v == x); end and function [y] = myfn( v

 Consider the following two functions written in Matlab: function [n] =

Consider the following two functions written in Matlab: function [n] = countval( v,x ) n= sum(v == x); end and function [y] = myfn( v ) A = 0); for x = V A = (A; x, countval(v,x)]; end max(A(:,2)); [m, n] = size(A); for i = 1:m if A(1,2) == t y = A(1,1); return end t = end Answer the following. a. Describe in plain English what the function countval is doing. b. If the vector v = (10, 3, 10, 10, 4), what matrix A is made by myfn(v)? (Try to answer this without using Matlab, and then use Matlab to check your answer.) c. Describe in plain English what the matrix A represents (for a general input vector v). d. Describe in plain English what the output of myfn represents (for a general input vector v)

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!