Stateflow fails to compile after calling Simulink from a Matlab script

5 views (last 30 days)
I am trying to run a fairly complex hybrid vehicle model in Simulink, using Matlab2012b. The model has always worked fine until now. Today I created a Matlab script to call the model, run its initialization file, run the model, and gather some data for post-processing. This script ran successfully, once. On the second execution, Simulink failed to run, with the following error messages: Coder Error - unknown - Stateflow - Failed to create file: "model path".h Model error - unknown - Simulink - error using sf, error using construct_error(line 108), failed to create file: "...path and name...".h
What's more, when I try to run the model just in Simulink, it gives the same error. Normal, Accelerator, Rapid Accelerator give the same error. I tried the usual troubleshooting steps (restarts, mex -setup, clearing out slprj and mex32 files), and I re-installed the c++ compiler. Same error. I have tried running Matlab as administrator, and different versions of Matlab. Same error. It's like this model is set to no longer compile correctly.
I can run Matlab scripts and other Simulink models just fine. I have searched the forums and tried the other suggested solutions, but it hasn't fixed the problem. Any ideas out there??

Accepted Answer

Zack Peters
Zack Peters on 25 Oct 2013
Hi Stefan,
This is just a guess at this point but it could be possible that your path names are too long. The Windows maximum path length is 260 Characters. Is the model in a directory with a long filename or is the model name itself quite long?
If so then try renaming the model to a shorter name and move it into a directory with a shorter path name.
~Zack
  1 Comment
Stefan
Stefan on 6 Nov 2013
Wow! I never saw any error or warning messages to this effect, but I renamed everything to be as short as possible, and suddenly everything works again. Well done sir!
I think this came about, in part, as the result of version control. We kept appending numbers and codes to the names over the course of development, and I guess we hit the limit. I didn't know about the Windows character limit , good to know.
Thanks!

Sign in to comment.

More Answers (1)

samir samir
samir samir on 20 Jul 2016
hello stefan,
I myself am currently designing a model of hybrid vehicle on Simulink matlab 2009
can you help me?
I arrived at the coupling phase.
I do not know how to continue?
I have designed vector control of the electric motor.
I modeled the battery, the chopper, the rectifier, the engine, the generatrice.
the rest I do not know how to combine these blocks via a DC bus and especially I have used a state flow control, (I'm beginner of stateflow) to simulate the states of this vehicle: stop startup, acceleration, braking (charging the battery ... etc).
at least is what you can advise me documentation for methodology forward to continue my project?
cordially. samir.

Categories

Find more on Programmatic Model Editing 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!