How can I configure string length in generated Simulink code?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 14 de Mayo de 2020
Editada: MathWorks Support Team
el 29 de Feb. de 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?
Respuesta aceptada
MathWorks Support Team
el 18 de En. de 2024
Editada: MathWorks Support Team
el 29 de Feb. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Deployment, Integration, and Supported Hardware en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!