Simulink model callback: Output to command line suppressed
Mostra commenti meno recenti
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 Commento
Bonpland
il 21 Nov 2018
Risposte (1)
Shlok
il 31 Ott 2024
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 use “disp” or “fprintf” for displaying messages in MATLAB.
For example, in Simulink model callbacks, you can use “disp” 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:
Categorie
Scopri di più su Model, Block, and Port Callbacks in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!