Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the function using matlab In this code, you will be evaluating the mini

ID: 3885594 • Letter: C

Question

Complete the function using matlab

In this code, you will be evaluating the minimum value of an input vector, provided there are three values in it. Inputs: Vector - A vector that contains three elements within it. Outputs: Minimum - The minimum value in Vector. Process: In this exercise, you will be using two if statements to find the minimum value of a three element vector. The steps are given below. Step 1: Make Minimum equal the first element of the input vector. Step 2: If the second element of the input vector is less than Minimum, make Minimum equal the second element of the input vector. Step 3: If the third element of the input vector is less than Minimum, make Minimum equal the third element of the input vector. Function Template: function Minimum = min3(Vector) %INSERT CODE end

Explanation / Answer

min3.m file

function Minimum = min3(Vector)
%Make Minimum as Vector 1st element
Minimum = Vector(1);

%if Vector(2) is less than Minimum make Vector(2) as Minimum
if(Vector(2)<Minimum)

Minimum = Vector(2);

end

%if Vector(3) is less than Minimum make Vector(3) as Minimum
if(Vector(3)<Minimum)

Minimum = Vector(3);

end

end

main.m file

Vector = [0,2,1];
min3(Vector)

%sample output

%ans = 0