Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Titus Edelhofer
Titus Edelhofer il 14 Giu 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 il 14 Giu 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.

Accedi per commentare.

Risposte (1)

Wendy Fullam
Wendy Fullam il 25 Set 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

Categorie

Scopri di più su Simulink Functions in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by