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

Write a function to find the minimum value of a vector and its index in the vect

ID: 3670332 • Letter: W

Question

Write a function to find the minimum value of a vector and its index in the vector using "for" and "if" statements and pass both values back out to a calling routine. The Gateway Arch in St. Louis has the shape of an inverted catenary. It rises 630 feet at its center and stretches 630 feet across its base. Write Matlab commands to sufficiently plot the shape of the arch which can be described by the following equation. y = -127.7 cosh(x/127.7) + 757.8 for -315 is less then equal to x is less then equal to 315

Explanation / Answer

Here is the code to find minimum value and index in matlab

xmin and imin will be returned as minimum value and its index respectively

function [xmin, imin]=find_min_val_index(x)

xmin=x(1);
imin=1;

% size(x,2) will give size of array x

% loop through the array x
for n=2:size(x,2)
if(xmin>x(n))
xmin=x(n);
imin=n;
end
end

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote