MATLAB: How to calculate a max value in a array without the built in functions.

forloopMATLABmaxwhilewithout built in functions

The array is
Time = [1,6,3,6,8,12,1]
I think you need to use a for or while loop. There is no predetermined max value however as it is time.
Thanks.

Best Answer

Giuseppe, a for-loop would be the way to go:
maxval = Time(1);
for ii = 1:length(Time)
if Time(ii) > maxval
maxval = Time(ii);
end
end
Alternatively, you could use max(Time).
Related Question