Simulink model callback: Output to command line suppressed

조회 수: 12 (최근 30일)
Bonpland
Bonpland 2018년 11월 21일
답변: Shlok 2024년 10월 31일 12:43
It seems that in the evaluation of model callbacks by Simulink, output to command lines, like
display('Hello World!')
is suppressed. Is this true? If yes, which other MATLAB commands are not evaluated in model callbacks?
  댓글 수: 1
Bonpland
Bonpland 2018년 11월 21일
As it turns out, this "feature" has been come up with by Simulink some time ago. Is there a workaround to enforce display of text in model callbacks?

댓글을 달려면 로그인하십시오.

답변 (1개)

Shlok
Shlok 2024년 10월 31일 12:43
Hi Bonpland,
Yes, the "display" function is now deprecated, and you'll start seeing a warning popup about it in R2022b and later versions.
Since, using “display” in your code may lead to warnings or unexpected behaviour, you can usedisp” or “fprintf” for displaying messages in MATLAB.
For example, in Simulink model callbacks, you can usedisp” as follows:
% Using ‘disp’ to display a message in the Simulink Diagnostic Viewer
disp('Hello World!');
You can also write output to a file using fprintf.:
fid = fopen('output.txt', 'a');
fprintf(fid, 'Hello World!\n');
fclose(fid);
The above methods ensure that your messages are displayed or logged appropriately without relying on the deprecated “display” function.
You can refer the following MathWorks documentation link to learn more about these alternatives:

카테고리

Help CenterFile Exchange에서 Model, Block, and Port Callbacks에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by