I have a c code i need to call the functions in the c code using s function in simulink… please someone give me the detailed procedure..
Best Answer
First create an S-function for the C-Code that you have. if you haven't deal with S-functions yet,Basic C MEX S-function will be a good start.
Once you have your C Mex S-function ready, Then Convert your .C file into a MEX file by typingMEX myfilename.C in your work space(Assuming filename as myfilename).
Then grab S-function block from your user-defined functions library in Simulink into your model. When you double click on the block it will ask you for the S-function file name and parameters that you want to pass on. In file name field give your s-function name, in this case myfilename.
To upgrade the “.mexsol” or "mex" files, you just need to remex those files using the “mex” command in the newer version of MATLAB, as described at the link below:
To upgrade the S functions, it is highly you likely that you also just need to use the “mex” command in the newer version of MATLAB (same procedure for “.mexsol”/"mex" files). If that does not work, then you may need to follow the workflow at the link below:
For the “.dll” files, you likely may continue using those files as is, because they are already written in C. If you do need to recompile the “.dll” files, you may use the links below:
This error occurs due to a limitation of the MCC command with the '-S' option. The 'MCC -S' option does not support passing parameters through the S-function, which is normally available in Simulink S-functions. Hence, the error message reports that the S-function expects 0 parameters, while you are actually passing 3 parameters to the S-function.
Best Answer