Can I specify which workspace to use with the LINMOD or LINEARIZE function?

2 views (last 30 days)
I want to call LINMOD from within another function by creating variables in my function workspace and using them as parameters in the model on which I call LINMOD. However, when using LINMOD, Simulink operates on the base workspace. I would like to be able to specify which workspace to use in a fashion similar to the 'SrcWorkspace' option for the SIM function.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Oct 2013
The ability to specify which workspace LINMOD and DLINMOD use is not available in Simulink.
To work around this issue, create the variables in the base workspace by using the ASSIGNIN function with 'base' specified as the workspace argument. For example, to create a variable 'x' with value 10 in the base workspace you would use the following command:
 
assignin('base','x',10)
 
This is also applicable to "linearize" function. An alternative workaround is to use the model workspace to save all the data required during linearization. The attached example linearizes a modified version of our documented example involving linearization of a water tank model in a function, and passes the linearized system to another function to generate bode plot. Download and unzip file 'linearize_modelWS.zip' and execute the following command at the MATLAB Command Window:  
 
>>linearize_inFcn
You can observe, neither the base workspace gets populated with any additional variables nor did you have to have any variable loaded in the base workspace to perform the linearization. If you open the Simulink model 'watertank_TS' and open its model workspace you will observe that the required variables are already saved in the model workspace. 

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!