- #1
BMY61
- 3
- 0
Homework Statement
Consider how you would pick the maximum value from a list (vector) of values. You take the 1st value in the vector and compare the next value to it. If the next value is larger, then select the next value as the max. You would continue like that moving on to the next value, next value, etc, until the end of vector is reached.
Write a user-written-function in MatLab (name that function as MyMax) to select maximum value from a vector which is given to MyMax as its input argument. Use a FOR loop and an IF statement inside the loop. Please test it by running it on MatLab for several different input value sets. Give the printout of the program to the instructor. Do NOT use any other MatLab function, except length, size, fprintf, and input
To test it, use the following:
A = input (‘ give 10 integer values ‘);
maxA = MyMax(A);
fprintf(‘Max val = %f\n’, maxA);
Homework Equations
The Attempt at a Solution
i have no clue how to create a user written function for this problem, does anyone have any ideas?