Do C++ STL functions work in S-function code?
Afficher commentaires plus anciens
I tried to print to stdout using std::cout << myMessage << std::endl, but the message does not appear, either in the console or the terminal from which I launched MATLAB, whereas printf works as expected. Why does std::cout not work?
Background:
- I created a minimal model, threeModel.slx, containing an S-Function block, in local directory working.
- I copied matlab/2016b/toolbox/simulink/simdemos/simfeatures/src/timestwo.c as working/three.cpp.
- I #include d iostream and cstdio into three.cpp .
- I inserted the following code into three.cpp at the end of function mdlOutputs: std::cout << "Testing cout." << std::endl; printf("Testing printf."):
- I compiled with MEX: >> mex three.cpp (Built normally.)
- I set the S-Function block's S-Function name parameter to three and left the other parameters with default settings (empty).
When I ran simulation (^T), I saw "Testing printf" (repeatedly) in the console window from which I had launched MATLAB, but no "Testing cout." Why not? Thanks!
Réponses (1)
Amittai Aviram
le 17 Jan 2017
0 votes
Catégories
En savoir plus sur Naming Conventions dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!