Matlab Function Block with error generated by Stateflow

6 views (last 30 days)
I have been trying to use "Matlab Function" block for hours using very simple example from this link http://www.mathworks.co.uk/help/simulink/ug/creating-an-example-model-that-uses-a-matlab-function-block.html (see attached file), however I keep getting this errors reported by "Stateflow" (The weird thing is I do not use Stateflow): Error using construct_error (line 108) The current directory is d:\program files\matlabr\bin, which is reserved for MATLAB files.
Please change your current directory to a writable directory preferably outside of MATLAB installation area.
What I have done:
1. Change to other directory outside of Matlab installation area
2. mex set up to select the correct compiler in my system (Microsoft Visual 2010)
3. Generate Code for the MATLAB Function Block by selecting Build Model > Build to compile and build the model.
I have no idea what went wrong, I am pretty sure this should be a very common issue, I keep searching high and low in the internet for the solution but to no avail...
Could you please suggest the possible cause of the problem?
Many thanks in advance.

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 10 Jul 2013
The MATLAB Function block and Stateflow share some common infrastructure, which is why you will sometimes see error messages as being reported by Stateflow. I'm surprised that you still see the same error even after changing the current working directory outside of MATLAB installation area though. What does running the command "pwd" at the MATLAB prompt return?
  5 Comments
Kaustubha Govind
Kaustubha Govind on 11 Jul 2013
The MATLAB Function block automatically generates C code from the MATLAB code for execution - this code is generated into the current working directory - and hence can "litter" your current working directory. In general, it is bad practice to litter the installation area with user data, which is why the error message is used to discourage this. Note that on newer Windows systems for instance, you need admin privileges to write to the "Program Files" directory.
It's not clear what you are asking in your second question. Are you saying that you are getting dimension propagation errors when using an S-function? If so, you may not have configured your S-function properly. However, this is a longer discussion, and if you would like to continue it, please create a new question.
want2know
want2know on 11 Jul 2013
Thanks for your detailed reply, it is very informative to me!
I have created a new question for the second question here http://www.mathworks.com/matlabcentral/answers/81495-s-function-dimension-matching-problem-with-lots-of-terminator-blocks, could you please spend couple of minutes to have a look on the link below, please, just give any keyword will do, I will try to find the details and understand, please

Sign in to comment.

More Answers (1)

want2know
want2know on 16 Jul 2013
Hi Kaustubha Govind,
Thanks for your detailed reply, it is very informative to me!
I have created a new question for the second question here http://www.mathworks.com/matlabcentral/answers/81495-s-function-dimension-matching-problem-with-lots-of-terminator-blocks, could you please spend couple of minutes to have a look on the link below, please, just give any keyword will do, I will try to find the details and understand, please

Categories

Find more on Simulink Functions 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!