필터 지우기
필터 지우기

Finding the indices of the maximum of a matrix for plotting

조회 수: 2 (최근 30일)
Jacob Stamm
Jacob Stamm 2020년 9월 27일
편집: KSSV 2020년 9월 27일
Hello, I'm trying to find the indicies of the maximum value of this matrix.
When I use the auto-index finder that's built into the 'max' function, it doesn't correspond to the maximum value of the matrix when plotted.
How do I find the indicies that correspond to the maximum value of m (when plotted)?
Any help is much appreciated.
clear;clc
load('x.mat')
load('y.mat')
load('m.mat')
figure
imagesc(x,y,m)
hold on
set(gca,'YDir','normal')
[maxval,maxidxX] = max(max(m,[],1));
[~,maxidxY] = max(max(m,[],2));
plot(x(maxidxX),y(maxidxY),'w*')

채택된 답변

KSSV
KSSV 2020년 9월 27일
편집: KSSV 2020년 9월 27일
load('x.mat')
load('y.mat')
load('m.mat')
[X,Y] = meshgrid(x,y) ;
Z = m ;
% Make Z equal to size of X, Y
Z(1,:) = [];
Z(:,1) = [] ;
% get max value
[val,idx] = max(Z(:)) ;
% plot
pcolor(x,y,Z)
shading interp
colorbar
hold on
plot(X(idx),Y(idx),'*r')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by