Stateflow:UnexpectedError when generating Simulink model code in 2011a
Show older comments
Hoping someone has seen this before. I try to generate code for my model and receive the following errors:
Making simulation target "MESR_MC_AC_ModeMgmt_sfun", ...
'MESR_MC_AC_ModeMgmt_sfun.bat' is not recognized as an internal or external command,
operable program or batch file.
A build_exception.mat file is created in the code output directory, and it contains an exception structure with the following identifier:
Stateflow:UnexpectedError
And a message that says:
'Error using ==> targetman>throw_make_error at 588
(SLSF Diagnostic)'
I'm on 2011a 64-bit, and using Microsoft Visual C++ 2010 Express compiler selected through mbuild -setup.
Any help would be much appreciated! Thanks! Justin
Answers (6)
Justin
on 19 Aug 2011
Kaustubha Govind
on 19 Aug 2011
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)
>> cd
>> !cd
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)
Justin
on 19 Aug 2011
0 votes
7 Comments
Kaustubha Govind
on 19 Aug 2011
Are you running on Windows 7 by any chance? If so, could you try starting MATLAB as Administrator and try again? My best bet is that Windows is not allowing MATLAB to generate any files to the folder.
Justin
on 19 Aug 2011
Kaustubha Govind
on 19 Aug 2011
Do you see MESR_MC_AC_ModeMgmt_test_sfun.bat inside the slprj folder? If yes, could you try running it from MATLAB like so:
>> !MESR_MC_AC_ModeMgmt_test_sfun
The Stateflow:UnexpectedError is coming from the Embedded MATLAB not being able to build generated code that it uses for execution. (Embedded MATLAB block uses some Stateflow-based infrastructure).
Justin
on 20 Aug 2011
Kaustubha Govind
on 22 Aug 2011
Sorry, I've run out of ideas with this. I would recommend contacting Tech Support to see if they can help. Good luck!
Justin
on 22 Aug 2011
Kaustubha Govind
on 24 Aug 2011
Justin: One other thing - have you run "mex -setup" on your R2011a installation? It appears that this issue happens sometimes when you have a stale mexopts.bat files that R2011a is picking up.
Stephen
on 30 Sep 2011
0 votes
I had the same problem Justin did, but Kaustubha Govind's suggestion to run "mex -setup" solved the problem for me when I upgraded from Matlab R2010a to R2011a.
Justin
on 30 Sep 2011
0 votes
Roque
on 8 Feb 2014
0 votes
I had the same problem, getting an error message that says:
'Error using ==> targetman>throw_make_error at 588 (SLSF Diagnostic)'
In my Simulink system I was using the Simulink Block "Matlab Function". I replaced that block with the "Interpreted Matlab Function" block and it worked perfectly.
I hope that this help.
Regards, Roque
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!