title: How to use the variables of a simulink model in matlab m file?
body: <p>I hope my keywords describe my situation. Basically, I'm working with SMC (Sliding Mode Control) in Simulink using simulink blocks and S Function blocks. Now, I want to use DE (Differential Evolution) algorithm, to determine the parameters of SMC that gives the best results. DE implemented by two m files, one of them contain a function for objective function (this need by DE), and the other one contain the rest of DE algorithm, used to running. What I did, is that, I converted one m file, to s function because it need some variables from the Simulink Model, my question is that,  now I want to use the value of the objective function in the other m file (DE algorithm) to run the DE to make some iterations. Hopefully, I'm clear.
  I found some stuff <a href="http://www.mathworks.com/matlabcentral/answers/42036-use-a-m-file-to-import-variables-in-to-a-simulink-matlab-function-box" rel="nofollow">here</a>, but it seems, I'm looking exactly for the opposite scenario.</p>