how to plot maximum and minimum point from excel column?

조회 수: 2 (최근 30일)
Tsvi Weiss
Tsvi Weiss 2016년 12월 16일
댓글: KSSV 2016년 12월 16일
I want to plot values of one column from excel file and mark all the minimum points in red * and maximum in green * this is what I got so far:
colA = xlsread('MinMaxVal.xlsx','B:B');
colB = xlsread('MinMaxVal.xlsx','B:B');
plot(colA);
hold on;
I defined colB to use it for marking the points.
tnx

답변 (1개)

KSSV
KSSV 2016년 12월 16일
k = rand(100,1) ; % a random data, in your case your column read from excel
plot(k) ;
hold on
% plot maximum
[val,id] = max(k) ;
plot(id,k(id),'*g')
% plot minimum
[val,id] = min(k) ;
plot(id,k(id),'*r')
  댓글 수: 2
Tsvi Weiss
Tsvi Weiss 2016년 12월 16일
tnx i tried it and it show me only one min and one max points how can i find the entire local min and max points of the values and plot them on the same line? picture added of the all the points marked in green *the excel table has 2 columns (A: date B:value of the date) and 96 rows of values of each date (2 to 97)
KSSV
KSSV 2016년 12월 16일
k = rand(100,1) ; % a random data, in your case your column read from excel
plot(k) ;
hold on
mu = mean(k) ;
idx = 1:length(k) ;
% plot all maximums
plot(idx(k>mu),k(k>mu),'*g')
% plot minimum
plot(idx(k<mu),k(k<mu),'*r')

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

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by