Determine the maximum with indexax function (plotyy)
이전 댓글 표시
Hello,
I have following Problem:
First at all in my workspace I have 3 times 5696x1 double values. These datas are: time, power and distance. I plot these 3 datas with the plotyy function.
[ax,p1,p2] = plotyy (time,power,time,distance);
Now I want to determine the (y)maximum of the distance and add a text. Therefore I want to use the indexmax function but it does not describe the problem for 2 y axes.
indexmax = find(max(Y2) == Y2);
xmax=x(indexmax);
ymax=y(indexmax;
- "Error in graph (line 8) xmax=x(indexmax);"
Thanks
채택된 답변
추가 답변 (1개)
dpb
2014년 12월 2일
What's Y2???
[dmx,idx]=max(distance); % the distance max, location
tmx=time(idx); % time of max distance
text(ax(2),tmx,dmx,num2str([dmx tmx],'Max D=%.1f at %.1fsec')
Fixup format string to suit, obviously, plus may want/need to adjust location/offset to avoid clutter. See
doc text
for details.
카테고리
도움말 센터 및 File Exchange에서 Two y-axis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
