Monday, May 27, 2013

Matlab Simulink Coder Compile Error _sfun.bat not found

I started to learn about Matlab Simulink Coder automatic C-Code Generation today. I followed the steps described in the very helpful tutorial Jose Carlos Molina Fraticelli (, but when i wanted to run the model, i got a Simulink error message, that a file called "modelname_sfun.bat" was not found.


The problem was caused by an incorrect setup of the C-Compilers on my system. I had multiple versions of Visual Studio installed on my computer and it seems like after a couple of update steps of Visual Studio and Matlab, Matlab got confused.
I had to rerun "mex -setup" from the Matlab command line and selected the Compiler Microsoft Visual C++ 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
After that, the model compiled OK and i was able to run it.