MATLAB: How to find the number of row in which the maximum value obtained for a particular column for loopmax value n = 3 B = rand(n) A = B for j = 1:length(A(1,:)) Amax = A(1,j); for i = 1:length(A(:,1)) if(A(i,j)> Amax) Amax = A(i,j); else Amax = Amax; end end Amax1(1,1)=Amax end Best Answer Read about the function max. A = rand(10) ; % 10*10 matrix [val,idx] = max(A(:,3)) % maximum value for the oclumn 3val = 0.9846idx = 4fprintf('The maximum value occurs in %d row\n',idx)The maximum value occurs in 4 row Related SolutionsMATLAB: GPU for loops indexing slow You can vectorize the inner loop, for j=m:-1:2 idx=j-1:-1:1; delta=(A(idx,j)/A(jj))*A(j,:); A(idx,:)=A(idx,:)-delta; end MATLAB: Trim Matrix and find the min-max value the reshaped matrix a=A(:,1:2:end)| b=A(:,2:2:end) [ii1,jj1]=min(a) [ii2,jj2]=max(a) [xx1,yy1]=min(b) [xx2,yy2]=max(b) Related QuestionEfficient loop – finding min and max index of certain valueHow to know the indices of multiple max valuesMin value callingValue of B at the maximum of AFind the minimum of a matrixI am using Matlab to generate the plots for the examples and have managed to plot the function. For clarity sake I would like to place a red triangle at the global maximum and a blue square at the global minimum on the plot. Can you help me figure
Best Answer