S-Function vector output without dimension defined
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Luca
el 18 de Jun. de 2025
Comentada: Luca
el 20 de Jun. de 2025
Hi all.
My question is:
Is it possible somehow define an output interface to generate a "C" S-Function with an output as vector with the dimension not defined?
For ex. if i defined
def.OutputFcnSpec=['void fc_MyFunc (int16 u1, uint8 u2[], y1[])'];
is not possible for y1 not indicate the dimension for my knowledge, it must define y1[dimension-vector] and not as possible for input u2[]
When i launch the
legacy_code('sfcn_cmex_generate', def);
an error is reported.
I found a very cumbersome way to do it manually, but I wanted to understand if there is a way to do it automatically through some particular semantics or command that I do not know.
My ultimate goal is to have a mex file to use as a Simulink block for the library usage of my SW component.
Thank you in advance,
LuLa
0 comentarios
Respuesta aceptada
Anushka
el 20 de Jun. de 2025
It is not possible to define an output (‘y1[]’) with undefined or variable dimension in the ‘OutputFcnSpec’ when using ‘legacy_code’ with 'sfcn_cmex_generate'. Unlike inputs, output dimensions must be explicitly defined in the function signature (e.g., ‘y1[10]’), because Simulink requires fixed output dimensions for S-Functions at compile time.
You can try the following workarounds:
1. You can use manual modification after code generation (as you mentioned).
2. You can use “mdlInitializeSizes” in a hand-written wrapper ‘S-Function’ to set output dimensions dynamically but this is not automated via ‘legacy_code’.
You can refer to the following documentation of “mdInitializeSizes” for a better understanding: https://in.mathworks.com/help/simulink/sfg/mdlinitializesizes.html
Hope this helps!
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulink Coder en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!