An easy way to execute complicated functions in Simulink is to use the Embedded MATLAB Function block. When you insert one of these blocks it creates a MATLAB file that is contained within the Simulink model block. The issue with this block is that only a subset of the full MATLAB language is available within an Embedded block. The simple solution to this problem is the function *eml.extrinsic* which sets certain functions to execute externally.

*Example:*

`eml.extrinsic('myfunction');`

[outputa outputb] = myfunction(inputa, inputb);

The function names within the *extrinsic* call will be set to run within MATLAB instead of Simulink. Now functions like *tf* and *ss* can be used!

Another Embedded MATLAB tip is to use ‘*1i’ to represent complex numbers. (This is mentioned in the MATLAB documentation but looks like ‘li’.)

*References:*

http://www.mathworks.com/help/toolbox/simulink/ug/f6-106261.html

### Like this:

Like Loading...

*Related*

Hi,

I have lot of matlab function in separate files. Can i use “eml.extrinsic” to only one function or need to use this for all function ? can you help?

The example I showed in this post was just for a single function, so I think it should work for you. I don’t actually have a copy of Simulink to test it myself anymore. If you have trouble maybe check that your .m files are in the same directory so there’s no path issues. Good luck!