フィルターのクリア

want to display the x value of the maximum in my graph?

34 ビュー (過去 30 日間)
Rehanos_boyzee
Rehanos_boyzee 2021 年 6 月 12 日
コメント済み: Adam Danz 2021 年 6 月 13 日
for the code below i want to display the maximum value of x on the graph can anyone please let me know thanks?
[GC,GR]=groupcounts (VarName8); % taking values from the excel sheet
area=table(GC, GR); % all areas with the number of trips to each have been totaled in this table in random order
sorted_area=sortrows(area,-1); % sorting the area and number of trips in a descending order
[Highest,index]=max(GC);
plot(GR,GC,'Linewidth',1.2,'color','b'); xlabel('Area Number'); ylabel('Total Trips');
grid on
hold on
plot(GR(index),GC(index),'r*'); text(GR(index),GC(index),'\leftarrow Maximum')
  2 件のコメント
Adam Danz
Adam Danz 2021 年 6 月 12 日
is VarName8 a column of data?
Rehanos_boyzee
Rehanos_boyzee 2021 年 6 月 12 日
Yes Var 8 is column of data that I'm taking importing from an excel sheet

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2021 年 6 月 13 日
Try this:
x=[1 2 3 4 5 6];
y=[5 6 7 6 5 4];
[highest,index] = max(y)
plot(x,y); text(x(index), y(index), '\leftarrow')
ylim([4, 8]);
grid on;
caption = sprintf(' maximum point at (x,y) = (%.1f, %.1f)', x(index), highest);
text(x(index), y(index), caption, 'FontSize', 12, 'Color', 'r', 'FontWeight', 'bold');
  2 件のコメント
Rehanos_boyzee
Rehanos_boyzee 2021 年 6 月 13 日
Thanks....
Adam Danz
Adam Danz 2021 年 6 月 13 日
You could insert the arrow directly within the label rather than plotting the arrow and label separately and starting the label with empty space.
x=[1 2 3 4 5 6];
y=[5 6 7 6 5 4];
[highest,index] = max(y);
plot(x,y);
ylim([4, 8]);
grid on;
caption = sprintf('maximum point at (x,y) = (%.1f, %.1f)', x(index), highest);
text(x(index), y(index), [' \leftarrow ',caption], 'FontSize', 8.5, 'Color', 'r', 'FontWeight', 'bold');

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by