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

EE 221 Computing for Engineers Homework # 12 1- Write a function that is called

ID: 1767013 • Letter: E

Question

EE 221 Computing for Engineers Homework # 12 1- Write a function that is called Get _Min1, which will take a Vector V as input and return a scalar value V as output. The function will do the following: Will get the length of the vector V. Initialize the minimum value Z to the first element in V c. Initialize the index value i 0 Will scan each element in the vector V using a while loop. Once all the elements in V are scanned, exist the while loop. a. b. d. e. Submit your Get_Min1.m file via blackboard. 2- Create a script and save it as HW12.m. The script will do the following a. Create a random column vector X of size (100x1) b. Save the vector X as MAT file called 'My_data1.mat' using the command save. c. Clear the workspace using the command clear. Note that the workspace is empty d. Load the vector X using the command load. e. Call the function Get Min10) function on the vector X and assign it to m1. The f. Compare the value of ml to the result of the building function min). The command E Run the script several times to create different random vectors. You sill will get the command looks like m1-Get Min1(x) looks like m2-min(X). You should get the same value. same min values (m1 m2) Submit your HW12.m file via blackboard

Explanation / Answer

Matlab Script for question 1:

function Z = Get_Min1(V)
V_len = length(V);%finding length
Z = V(1);%initializing with first element
i = 0;%initializing index value with 0
while i<V_len %scanning all the elements
if V(i+1)<Z %checking if current element from V is less than Z if so we replace Z with current element of V
Z = V(i+1);
end
i = i+1;
end
end