Determine the maximum with indexax function (plotyy)
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (1)
dpb
el 2 de Dic. de 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.
Categorías
Más información sobre Two y-axis en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
