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 endAlternatively, you could use max(Time). Related SolutionsMATLAB: Find the maximum value and its location from a matrix using two nested loops you can do it as follow: MaxValue = -Inf; row = 0; column = 0; for i = 1:size(K, 1) for j = 1:size(K, 2) if K(i, j) > MaxValue MaxValue = K(i, j); row = i; column = j; end end end MATLAB: Find max value in each column of a 6×5 matrix without using built in matlab functions. Hi, based on your code a few modifications will make it work:A=randi(100,6,5)maxvalue = zeros(1,5);for columns=1:5 column=A(:,columns); for columndown=1:6 columnval=column(columndown); if columnval>maxvalue(columns) maxvalue(columns)=columnval; end endendmaxvalue %show the row with max value for each column :-) Related Question
Best Answer