write a simple m-file where the input is a row vector which is 2 or more compone
ID: 3641668 • Letter: W
Question
write a simple m-file where the input is a row vector which is 2 or more components row vector of numbers. output should be the second largest number element. :
x is a row vector of size n >= 2.
y is the second largest element in x.
You are allowed to use the built-in “max” function, but not allowed to use the “sort” or “unique” function.
Explanation / Answer
function [x] = findSecondMaxNum(a) %Finds the max value in a row vector of elements > 2 %The command will find the next number smaller than %the max number in a matrix a %the second largest number will be returned. a = [2 4 7 9]; maxNum = max(a(aRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.