Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
Sebastian
Sebastian el 14 de Jun. de 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 comentarios
Titus Edelhofer
Titus Edelhofer el 14 de Jun. de 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 el 14 de Jun. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Wendy Fullam
Wendy Fullam el 25 de Sept. de 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

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by