Plot a vertical ligne from the maximum of a function
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, Let say that I have a function f(x) and x=[x1,x2,...,xn] the values that can x take it, so for example if f(x) reach a maximum at x5. How can I plot a vertical line from the maximum point in the plot of the function f(x) to x5 in x axis.
0 comentarios
Respuestas (1)
Image Analyst
el 2 de Dic. de 2016
Assuming x5 is the index of your vector "f" where the line should be drawn, try this:
[yMax, xMax] = max(f); % xMax is an integer index 1,2,3, or 4,.....not a floating point value.
yl = ylim();
line([xMax, xMax], [yl(1), yMax], 'Color', 'b', 'LineWidth', 2);
grid on;
0 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!