Determine the maximum with indexax function (plotyy)
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (1)
dpb
am 2 Dez. 2014
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.
Kategorien
Mehr zu Two y-axis finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
