필터 지우기
필터 지우기

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
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 CenterFile Exchange에서 Develop 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