How can I configure string length in generated Simulink code?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 14 Mai 2020
Bearbeitet: MathWorks Support Team
am 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?
Akzeptierte Antwort
MathWorks Support Team
am 18 Jan. 2024
Bearbeitet: MathWorks Support Team
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Deployment, Integration, and Supported Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!