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] =](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f329d360973_98666f329d2f1608.jpg)
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
Get step-by-step solutions from verified subject matter experts
