Support variable size arrays with embedded coder

Hi, is there a way in which a calibratable arrays can be supported in Simulink. For example, we want to develop a generic model that can work with a different number of sensor inputs depending on the hardware configuration without having to change the model. I tried using selector block and a port to specify which index to use, this works in simulation but fails during code generation as variable size signals are not supported. Thank you.

답변 (1개)

dpb
dpb 2026년 6월 8일 14:55

0 개 추천

I don't know Simulink, but a search indicated that it is possible to use a variable sized signal <Variable Size Signal Basics> and set a maximum allowable number. The code is then generated based on memory allocation to that max model size but the unused signals in a given simulation have zer length.
Apparently there is a configuration parameter for the code generator to handle it...
  • The signals carry a maximum dimension but pass a runtime signal containing the actual size being used.
  • How to configure: Open your Model Configuration Parameters → Code GenerationInterface, and set Support: variable-size signals (Embedded Coder) to On.

카테고리

도움말 센터File Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2026년 6월 8일 11:07

답변:

dpb
2026년 6월 8일 14:55

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by