Line plot in a loop
Mostrar comentarios más antiguos
My code to plot the progress of my Newton's method algorithm vs. time currently looks like this:
f = @(x) % function
while % [not terminating condition]
% [Newton's method]
plot(t,log(abs(f(z))), '*-')
end
But of course, the '-' in the linespec doesn't do anything, since only a point, not a line, is being plotted in each iteration. How can I plot a solid line linking the last point plotted to the new one? I know I could store previous t and z and do plot([t_old t],[log(abs(f(z_old))) log(abs(f(z)))]) each time, but that is not ideal, especially since log(abs(f(z_old))) would need to be recalculated each time. There must be a smarter way, using a plot handle or line handle or some such. Can you help? Thank you.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!