Mexing s-function with compiler flag -fshort-double fails....

4 vues (au cours des 30 derniers jours)
Sebastian
Sebastian le 14 Juin 2011
Hello,
for numerical tests of a filter algorithm implemented in C++ (testing/simulation environment is a larger simulink project) I would like to switch to single precision variables. For the gcc/g++ the option -fshort-double seems to make switching to single precision very comfortable, because it basically shrinks doubles to the size of floats.
However I get the following warning when mexing the algorithm:
/opt/matlab/v24/simulink/include/simulink.c: In function ‘int_T ssWriteRTWParamSettings(SimStruct*, int_T, ...)’: /opt/matlab/v24/simulink/include/simulink.c:1538: warning: ‘real_T’ is promoted to ‘double’ when passed through ‘...’ /opt/matlab/v24/simulink/include/simulink.c:1538: note: (so you should pass ‘double’ not ‘real_T’ to ‘va_arg’) /opt/matlab/v24/simulink/include/simulink.c:1538: note: if this code is reached, the program will abort
As stated in the warning, the simulation doesn't run, but gives the error: Invalid sizes vector returned by MEX S-function
Can this be resolved or does anybody have an alternative way of testing an S-function with single precision.
Regards, Sebastian
  2 commentaires
Titus Edelhofer
Titus Edelhofer le 14 Juin 2011
Hi Sebastian,
I understand you are writing a Simulink S-function? I would not use the flag for the compiler but tell the S-function to take single precision inputs/outputs and parameters...
Titus
Kaustubha Govind
Kaustubha Govind le 14 Juin 2011
I agree with Titus. What you are doing will cause problems because the Simulink engine allocates and reads from signals and parameters that are supposedly double, but when it dispatched a call to MEX, it is really accessing single variables.

Connectez-vous pour commenter.

Réponses (1)

Wendy Fullam
Wendy Fullam le 25 Sep 2012
Answered in comments by Titus
Hi Sebastian,
I understand you are writing a Simulink S-function? I would not use the flag for the compiler but tell the S-function to take single precision inputs/outputs and parameters...
Titus

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by