MATLAB: How to find maximal values in matrix maximum I have a matrix: A =[1, 128; 2, 300; …;20, 500;…;99, 10; 100, 0]; the row I need to extract be B=[20,500], with 500 is maximal value of 2sd colum. How I can do? Best Answer This works:A =[1, 128; 2, 300;20, 500;99, 10; 100, 0];B = A(A(:,2) == max(A(:,2)),:)B = 20 500It compares the second column of ‘A’ with the maximum of the second column of ‘A’, and then selects that entire row. Related SolutionsMATLAB: Matrix row/column augmentation You can use F=a*(ones(20,20)). MATLAB: Highlight cells in heatmap You can do so by creating a custom colormap. The code below shows a simple implementation.xvalues = 1:5;yvalues = 1:5;cdata = randi(20,[5,5]); % range of values in cells < 20cmap = [repmat([1 0 0],5,1) repmat([1 1 1],5,1) % highlight all cells with values from 5-10 with white repmat([0 0 0],10,1)]; % highlight all cells > 10 with blackheatmap(1:5,1:5,randi(20,[5 5]),'Colormap',cmap); Related QuestionDisplay maximal value in a range
Best Answer