In this code, you will be creating the function min2 which evaluates the minimum
ID: 3167413 • Letter: I
Question
In this code, you will be creating the function min2 which evaluates the minimum value of a 2 element vector.
Inputs:
Vector - A vector that contains two elements within it.
Outputs:
Minimum - The minimum value within Vector.
Process:
Step 1:Make Minimum equal the first value of the input vector.
Step 2:If the second value of the vector is less than Minimum, make Minimum equal the second value of the input vector.
Note: The following functions are banned in this exercise: min, max, sort, elseif, else.
Function Template:
function Minimum = min2(Vector)
%INSERT CODE
end
Explanation / Answer
function Minimum = min2(vector)
Minimum = vector(1);
if (vector(2) < Minimum)
Minimum = vector(2);
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.