I added Visual Studio 2013 as the default C compiler for MATLAB using the mex -setup
command. I added Visual Studio 2013 using a download I found on the internet with the following instructions.
The files
* msvc120engmatopts.bat
* msvc120opts.bat
* msvc120opts.stp
should be copied to C:\Program Files\MATLAB\R2013a\bin\win64\mexopts .
The files
* msvc120compp.bat
* msvc120compp.stp
should be copied to C:\Program Files\MATLAB\R2013a\bin\win64\mbuildopts .
My version of MATLAB is R2011b, so I replaced the path appropriately.
Here's me using it to run a C function to verify if the compiler has been linked.
I found out about this method from this answer.
However, when I use a MATLAB function within a Simulink Model, I get the following error message just like I did before I linked the VS2013 compiler to MATLAB.
Unable to locate a C-compiler required by Stateflow and MATLAB Function blocks.
Use 'mex -setup' to select a supported C-compiler.
Okay, so the only thing that works for my version of MATLAB "R2011b" is Microsoft SDK 7.1 since the other compilers are too old for Windows 7 64 bit. MinGW-64 bit is unsupported. Although it works on MATLAB it is not recognized by Stateflow.
So I just downloaded the .iso file from here.
If you face any difficulty while installing the SDK, then try this.