Print in workspace during simulink simulation

조회 수: 3 (최근 30일)
Hugo Mendonça
Hugo Mendonça 2014년 7월 20일
답변: Vidhi Agarwal 2024년 9월 17일
Hi, Folks!
I have a simulink system with S-function block. In this S-function I do some calculations that I would like to print during the simulation in the Matlab workspace.
I have done the algorithm in S-function Builder under Outputs. However, the results is given just when the simulation overs and not each time during the simulation.
Any idea?
I appreciate your contribution.

답변 (1개)

Vidhi Agarwal
Vidhi Agarwal 2024년 9월 17일
I understand you are facing an issue in printing the values during the simulation, but you have an algorithm in S-function Builder under Outputs, which gives result after simulation is over. Here are some strategies to resolve this issue:
  1. Ensure you're using “disp” or “fprintf” to print messages and follow it with “drawnow” to force MATLAB to update the Command Window immediately.
  2. Run your simulation in “Normal mode”. Other modes like Accelerator or Rapid Accelerator may not execute MATLAB code in real-time.
  3. Ensure your print statements are within the “Outputs” or “Update” functions of the S-Function, as these are called during each simulation step.
  4. If you want to capture all printed output to a file for review, use the “diary” function.
For better understanding of drawnow and dairy, refer to the following documentation:
Hope that Helps!

카테고리

Help CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by