Incorrect code generation by simulink

Hi,
I used a min library block in my model and the code generated for that used a fmin # define which was defined as below:
#define fminf(x,y) (x < y) ? x : y
This creates a problem when first argument is another fminf() statement. For example,
fminf(fminf(x, y), z)
The expanded form will look like this: ((x<y)?x:y<z)?(x<y)?x:y:z
This gives unexpected results.
If I update the #define as below, it works perfectly fine:
#define fminf(x,y) (((x) < (y)) ? (x) : (y))
Is this a bug? Is there a simulink option to say like "Do not generate code with ternary operator"?
Thank you.

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Simulink Functions 的更多信息

产品

版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by