Line plot in a loop
显示 更早的评论
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.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 2-D and 3-D Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!