All Stateflow charts and Embedded MATLAB blocks generate C code and compile them for execution, the compiler selected using the MEX -SETUP command is invoked for the compilation and linking process. At this time, MATLAB spawns a system shell to run the compiler/linker commands. By default, the spawned shell starts in MATLAB's current directory - which means that the relevant batch/source/object file is expected to be in the present working directory.
However, if your system is configured to start the system shell in a different directory than the current one, this assumption fails.
To verify this execute the following commands in MATLAB (they should return the same path for the default configuration)
If you find that the second command returns a different folder, check to see if you have made any settings to force a starting directory for cmd.exe. (One way that such a setting can be made is using the Windows Registry keys HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun (or) HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun)
Another thing to make sure is that you're not working in a UNC path (ie, a network directory that has not been mapped to a letter)