how to plot maximum and minimum point from excel column?

3 ビュー (過去 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 Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by