Is there a way to find the max value in an array without using the "max" command?
86 visualizzazioni (ultimi 30 giorni)
Cris LaPierre il 16 Gen 2020
Modificato: Cris LaPierre il 16 Gen 2020
The max function is just an implementation of an algorithm that compares the values in the vector to find the one with the highest value. You assignment, therefore, is to implement your own algorithm. I'd perhaps start with
if x(1) > x(2)...
Murugan C il 16 Gen 2020
with the help of for and if, we can create a function to find max value in given array. If it is vector, use two for loop for row and col.
function max_Value = find_maxValue(Input)
max_Value = Input(1);
for i1 = 1 : length(Input)
if Input(i1) > max_Value
max_Value = Input(i1);