Inport Outports ranges in the generated code

조회 수: 5 (최근 30일)
Davide Frey
Davide Frey 2018년 12월 12일
답변: Sourabh 2025년 6월 10일
Hallo,
I'm trying to do the code generation for a model. I was wondering if there is a way to include the specified ranges in inports/outports in the code. At the moment, the only related option I've found is "Optimize using the specified minimum and maximum values", though what I need is a way to have some hard limits on the variables generated in the code.
Thanks for the help.
Davide

답변 (1개)

Sourabh
Sourabh 2025년 6월 10일
In Simulink code generation, using Embedded Coder, minimum and maximum values specified on Inports/Outports are primarily used for simulation range checking and optimization, but not directly enforced as hard constraints in the generated code by default.
To include hard limits in the generated code based on specified ranges, you’ll need to explicitly model them or configure code generation settings accordingly. One technique is to use Saturation Blocks:
  • Add Saturation blocks right after Inport blocks or before Outport blocks.
  • Set the upper and lower limits to the desired min/max values.
  • These limits will be hard-coded into the generated code as conditional logic or min/max functions.
For more information on “Saturation block, kindly refer the following MATLAB documentation:

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by