call MEX-Funcion in a simulink userdefined block
Mostrar comentarios más antiguos
Hi, I have a MEX-function that have several inputs and 2 outputs. In addition I creat a simulink model whit several blocks. I need to call the MEX-Function whit these blocks in the model. how can I do it? It's important for me that arrive to minimum executing and calling time.
Respuestas (1)
Kaustubha Govind
el 30 de Abr. de 2013
1 voto
MEX-functions can essentially be called just like any other MATLAB function. Please see the available MATLAB Function blocks to find a Simulink block that can be used to execute a MATLAB function.
6 comentarios
Kaustubha Govind
el 1 de Mayo de 2013
Omid: Considering that you don't have the actual source code to the MEX-function, I don't see any advantage in calling into the MEX-function via a C S-function - I would wager that the performance will be equivalent to using the MATLAB Function block. Btw, I think the standard way to call MEX-files from C is using mexCallMATLAB. I don't know how LoadLibrary needs to be configured to do this.
omid jab
el 2 de Mayo de 2013
Kaustubha Govind
el 2 de Mayo de 2013
Please look at the examples listed at the bottom of the documentation page that I previously linked for mexCallMATLAB.
omid jab
el 6 de Mayo de 2013
Kaustubha Govind
el 6 de Mayo de 2013
omid: You need to create mxArray's for both - use mxCreateString for the first and mxCreateDoubleScalar for the second.
Categorías
Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!