Is it possible to automate the plotting of data that is created by multiple passes of the same script?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Adam
le 26 Oct 2015
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.
Réponse acceptée
Jan
le 26 Oct 2015
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!