- sim - https://www.mathworks.com/help/simulink/slref/sim.html
- addpoints - https://www.mathworks.com/help/matlab/ref/addpoints.html
- drawnow - https://www.mathworks.com/help/matlab/ref/drawnow.html
- toWorkspace - https://www.mathworks.com/help/simulink/slref/toworkspace.html
Plotting for every Iteration and refreshing the Previous plot in the Figure.
    2 ビュー (過去 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.
0 件のコメント
回答 (1 件)
  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!
0 件のコメント
参考
カテゴリ
				Help Center および File Exchange で General Applications についてさらに検索
			
	製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

