Plot of maximum value of chosen column in matrix

조회 수: 2 (최근 30일)
다시 열림: madhan ravi 2018년 11월 15일
 clear
 close all
 clc
 t = linspace(0,10,15);
 t = t';
 rng default
 M = rand(15,5);
 plot(t, M(:,1));
 max_M = max(M); %maximum of each column
 max = max(max(M)); %total max

I would like to plot maximum value of first column of matrix M(:,1); and indicate this information on a plot.

Something like this:

답변 (2개)

madhan ravi
madhan ravi 2018년 10월 23일
편집: madhan ravi 2018년 10월 23일
t = linspace(0,10,15);
t = t';
rng default
M = rand(15,5);
plot(t, M(:,1));
hold on
m = M(:,1)
[P,K]=findpeaks(m)
plot(t(K(1)),P(1),'x')
hold off
  댓글 수: 4
starting_point, ending_point - You mean I should define here X abscissa?
madhan ravi
madhan ravi 2018년 10월 23일
Check the edited answer now

댓글을 달려면 로그인하십시오.


jonas
jonas 2018년 10월 23일
편집: jonas 2018년 10월 23일
In this case you could simply find the max in each column in one go
[vm,idx] = max(M); %maximum of each column
plot(t,M);
scatter(t(idx),vm,'rx');
would you prefer to plot only the max of the first column, then
scatter(t(idx(1)),vm(1),'rx')

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by