Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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] = 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started