How can I configure string length in generated Simulink code?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 14 Mag 2020
Modificato: MathWorks Support Team
il 29 Feb 2024
I am attempting to generated code for a Simulink model that contains a "String Constant" block which outputs a "string" type. I noticed that in the generated code, the length of the character array for the "String Constant" defaults to 256. How can I configure this to a custom value?
Risposta accettata
MathWorks Support Team
il 18 Gen 2024
Modificato: MathWorks Support Team
il 29 Feb 2024
There are two different ways to configure the generated code in this way. The first is block-specific, while the second is a model-wide configuration.
For the block-specific solution, please change the "Output data type" parameter of the "String Constant" block. Instead of using "string", you should be able to change it to "stringtype(n)" where "n" is the maximum length of the string.
For more information on "Simulink Strings", please run the below command in the MATLAB R2018b command window to get the release specific documentation:
web(fullfile(docroot, 'simulink/ug/simulink-strings.html'))
Further, for the model-wide solution, please configure the buffer size of dynamically-sized strings. This can be done by navigating to Model Configuration Parameters > Code Generation > Interface > Advanced Parameters, and changing the "Buffer size of dynamically-sized string (bytes)" parameter. Please run the below command in the MATLAB R2018b command window to get the release specific documentation that discusses more about the "Buffer size of dynamically-sized string (bytes)":
web(fullfile(docroot, 'rtw/ref/buffer-size-of-dynamically-sized-string-bytes.html'))
Please follow the below link to search for the required information regarding the current release:
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Deployment, Integration, and Supported Hardware in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!