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

1 次查看(过去 30 天)
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.

回答(1 个)

ag
ag 2025-4-23
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!

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by