Question: Problem 2 Because I use Matlab, I want the right answer for Matlab program. You are to write a function called setplay which receives an

Problem 2

Problem 2 Because I use Matlab, I want the right answer for

Matlab program. You are to write a function called setplay which receives

an arbitrary number of numeric vectors and has the following three properties:

Note: You may NOT use the MATLAB built-in functions intersect, union, unique,

Because I use Matlab, I want the right answer for Matlab program.

You are to write a function called setplay which receives an arbitrary number of numeric vectors and has the following three properties: Note: You may NOT use the MATLAB built-in functions intersect, union, unique, setdiff. Note: You should use varargin/varargout for input/output. i) When a single output is expected at call, the function returns a single vector obtained as the concatenation of the individual input vectors passed to the function, e.g.: >> setplay([11, 8], [5, 1, 8, 2]) ans = 11 8 5 1 8 2 >> a = setplay([2, 5, 1], [9, 3, 7, 1], [3, 5]) a = 2 5 1 9 3 7 1 3 5 When a second (optional) output is expected at call, the function returns for the first output the same as in case (i), while for the second output it returns the same elements as in the first output vector but with no repetitions, e.g.: >> [a, b] = setplay([11, 8], [5, 1, 8, 2]) a = 11 8 5 1 8 2 b = 11 5 1 8 2 >> [a, b] = setplay([2, 5, 1], [9, 3, 7, 1], [3, 5]) a = 2 5 1 9 3 7 1 3 5 b = 2 9 7 1 3 5 When and a third (optional) output is expected at call, as in [a b c] = setplay(vec1, vec2, ...), the function returns for the first and second output the same as in case (ii), while for the third output it returns vector of indices such that a(c) = b. For example: >> [a, b, c) = setplay([11, 8], [5, 1, 8, 2]) a = 11 8 5 1 8 2 b = 11 5 1 8 2 C= 1 3 4 5 6 >> [a, b, c) = setplay([2, 5, 11, 19, 3, 7, 11, [3,5]) a = 2 5 1 9 3 7 1 3 5 b = 2 9 7 1 3 5 1 4 6 7 8 9 Code to call your function 1 a = setplay([2, 5, 1], [9, 3, 7, 1], [3, 5]) 2 [a, b] = setplay([11, 8], [5, 1, 8, 2]) 3 [a, b] = setplay([2, 5, 1], [9, 3, 7, 1], [3, 5]) 4 [a, b, c] setplay([11, 8], [5, 1, 8, 2]) 5 [a, b, c] = setplay([2, 5, 1], [9, 3, 7, 1], [3, 5]) =

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!