0
votes

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?

http://imgur.com/RuxFCs6

Many thanks in advance.

1

1 Answers

0
votes

That's probably because even though you do not use Stateflow, the MATLAB Function use the same core technology as Stateflow for generating the code, so the error is reported as a Stateflow error.

You say you have changed to another directory outside of the MATLAB installation area. Is your model actually in that directory (i.e. have you actually moved the file? Otherwise it won't change anything)? Is you directory actually writable? Does mex -setup run OK? When do you get your error message? I don't think you need to build the model as such, just press play to run it, and the code generation for the MATLAB function should automatically happen.