1. Write a function file to find both the minimum and maximum values of elements in a vector and to return their locations in the vector i.e.elements 3 and 5 for example). Use the following as a guideline function (xminimin xmax,imax] = vec_min_max(x) % date, student name % x is a vector % xmin = minimum element in vector x % imin = location of minimum element % xmax = maximum element in vector X % imax = location of maximum element % first check the length of the vector X n = length(x); xmin = x(1): xmax = x(1); for i = 1:n; % place if and elseif statements, etc. here % with the mathematical operations end % end of for loop end % end of function file confirm your results using the following vector x = [14.7 -12.3 33.2 41.7 12.1 27.0 -22.1 14.7 55.3 6.2 - 12.7]
没有找到相关结果