Hi Nima,
It may be possible to generate C code from your Simulink model that includes your M-S-Function block using the Simulink Coder's code generation technology. However, there are several requirements that your M-S-Function block and associated classes must meet in order for this to work.
Firstly, the classes used in your M-S-Function block must be defined using MATLAB classes that are supported by Simulink Coder's code generation. Specifically, only a subset of MATLAB classes is supported, and not all classes can be used in code generation.
Secondly, any MATLAB code that is used in your M-S-Function block must be compatible with code generation. In practical terms, this means that the MATLAB code used in your M-S-Function block should not include any constructs or functions that are not compatible with code generation, such as certain built-in functions, unsupported toolboxes, or MEX files.
Finally, your M-S-Function block and associated classes should adhere to certain design guidelines for code generation. For example, you should avoid using dynamic memory allocation, avoid using global variables, and avoid using recursive function calls.
If you are able to meet these requirements, you can generate C code from your Simulink model using the Simulink Coder. You can go through the documentation if you need any help in generating C code from a simulink model.
Hope it helps!