Is it possible to automate the plotting of data that is created by multiple passes of the same script?
3 次查看(过去 30 天)
显示 更早的评论
For example the script runs once and creates a set of data, then runs again (overwriting previous data). I need all data on same plot.
I can save each plot separately and then reassemble once all plots are created, however a simpler way would be preferred so all that would have to be done is running the program and all data would go to the same plot without being overwritten.
1 个评论
Adam
2015-10-26
Just change your script into a function and do the plotting in a script or function that then calls it multiple times.
You could probably still do that with a script, but depending what is in the script it may be more complicated. Functions are generally better than scripts, especially if you want to do the same thing repeatedly, but with different data.
采纳的回答
Jan
2015-10-26
Create the axes object with enabling the adding of new lines:
AxesH = axes('NextPlot', 'add', 'Tag', 'ThisIsMyFixedAxes');
When the script runs the next time, it does not create the axes, if it is existing already:
AxesH = findobj('Tag', 'ThisIsMyFixedAxes')
if isempty(AxesH)
AxesH = axes('NextPlot', 'add', 'Tag', 'ThisIsMyFixedAxes');
else
axes(AxesH); % Make it the current axes object
end
Instead of axes(AxesH) it would be smarter to add the axes' handle as a parent in the plot command:
plot(1:10, rand(1, 10), 'Parent', AxesH);
0 个评论
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!