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 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!