Joachim
2009-07-10 13:35:03 UTC
Hi,
I have a ready-written MATLAB m-function and want to implement it in a Simulink model.
I've read many tutorials and the MATLAB help about it, but I don't get it to do what I want it to do. ;)
The m-function uses the fmincon function from the optimization toolbox.
How can I implement this in an S-Function which I can build with the Real-Time Workshop?
If I understood the help, I have to write a Level 2 M-File and have to create a *.tlc file for it. Creating a fully inlined function works (I tested a very simple Input = Output - no "special" function), but when I want to use the "wrapper" method, I'm failing with creating the correct call for my function and to "let MATLAB know about it".
Is it possible to do what I want to do (implementing a MATLAB toolbox function in an RTW)?
If it is, how does it work and could you give me a brief example of a similar problem? It hasn't to be the fmincon, any non-standard function (not sin, cos etc.), e.g. the interp1 would help me to understand what I have to do.
If it doesn't work, please let me know... then I would have to create my own "fmincon" or use another function which source code is available.. but even then I have to "wrap" the function and I have no clue how to do this.
Greetings,
Joachim
I have a ready-written MATLAB m-function and want to implement it in a Simulink model.
I've read many tutorials and the MATLAB help about it, but I don't get it to do what I want it to do. ;)
The m-function uses the fmincon function from the optimization toolbox.
How can I implement this in an S-Function which I can build with the Real-Time Workshop?
If I understood the help, I have to write a Level 2 M-File and have to create a *.tlc file for it. Creating a fully inlined function works (I tested a very simple Input = Output - no "special" function), but when I want to use the "wrapper" method, I'm failing with creating the correct call for my function and to "let MATLAB know about it".
Is it possible to do what I want to do (implementing a MATLAB toolbox function in an RTW)?
If it is, how does it work and could you give me a brief example of a similar problem? It hasn't to be the fmincon, any non-standard function (not sin, cos etc.), e.g. the interp1 would help me to understand what I have to do.
If it doesn't work, please let me know... then I would have to create my own "fmincon" or use another function which source code is available.. but even then I have to "wrap" the function and I have no clue how to do this.
Greetings,
Joachim