Plotting for every Iteration and refreshing the Previous plot in the Figure.

1 vue (au cours des 30 derniers jours)
Sriharsha
Sriharsha le 4 Fév 2015
Réponse apportée : ag le 23 Avr 2025
I have a continuous signal data coming from a Simulink Model,for infinite Time. I want to capture that data and plot the data for every Iteration. How do i plot the data in single figure for every iteration, refreshing the old plot? I mean, i want to plot a fresh figure for every iteration. The problem is, i do not know the number of iterations. Generally we use 'hold on' to plot in the same Figure. But i dont to plot previous data. I want to refresh the previous data with current data, but, i would like to use only one figure, as we use 'hold on'. I dont want multiple figures to pop up for every iteration. Kindly help me.

Réponses (1)

ag
ag le 23 Avr 2025
Hi Sriharsha,
To update the existing plot with new data, you can use the MATLAB function "drawnow". The below code snippet demonstrates how to achieve the same:
% Rest of the code
% Loop start
simin = Simulink.SimulationInput('your_model_name');
% Run the Simulink model
simOut = sim(simin);
%Please note that addpoints takes (animatedLine, x, y) as input argument, and you will need
% to process the "simOut" variable to get the "x" and "y" values before calling "addpoints" method.
addpoints(an, simOutX, simOutY);
drawnow
% Loop end
For more details, please refer to the following MathWorks documentations:
Hope this helps!

Catégories

En savoir plus sur General Applications 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!

Translated by