Matlab: How do I provide input to a Simulink model without placing it in the workspace?

It's not obvious, but you can input/output data from the sim() command and a calling function's workspace. I've done it before & have an example at work but can't get there until Monday to verify. However, try the solution listed on Mathworks's site.

It's not obvious, but you can input/output data from the sim() command and a calling function's workspace. I've done it before & have an example at work but can't get there until Monday to verify. However, try the solution listed on Mathworks's site: Solution: When using variable mask parameters in Simulink, the base workspace is the default source workspace of Simulink.

However, by using the SIMSET command, this workspace can be changed. SIM is then used with this options structure created by SIMSET. The following is an example on how to do this.

Options = simset('SrcWorkspace','current'); sim('modelname',,options) ...although apparently this got deprecated in R2009b due to incompatibility with the Parallel Computing Toolbox >:( Looks like the correct solution is to explicitly push variables into the simulation's model workspace (different than the base workspace), using assignin(). http://www.mathworks.com/matlabcentral/newsreader/view_thread/292544 You have 2 options: For releases before R2009b, look at the SIMSET documentation. It allows you to set the "SrcWorkspace" property to "current" to use the data from your function.

http://www.mathworks.com/support/solutions/en/data/1-1BWDA/?solution=1-1BWDA In newer releases, this option is deprecated because it is not compliant with the Parallel Computing Toolbox and PARFOR. What I recommend is: http://www.mathworks.com/support/solutions/en/data/1-ASPEIV/?solution=1-ASPEIV.

– MajorApus Mar 12 '11 at 22:11 that you'd have to ask the folks at Mathworks; I've never used RTW, or gotten that deeply into Simulink other than running simulations from an M-file. – Jason S Mar 12 '11 at 22:24 The first option works in 2009a... so I'm just gonna stick with that till it bites me. Thanks!

–? _? Mar 14 '11 at 22:07 @MajorApus We're using RTW and the first solution appears to work.

–? _? Mar 14 '11 at 22:07.

You can use the evalin() function to execute from your own function a MATLAB expression (as a string) in a specific workspace, in your case the 'base' for SIMULINK to find them. However, if you do not want to use the workspace directly then you can load and save the signals or variables from/to MAT files using the From/To File blocks.

Short answer: No. I could be wrong, but let me give you some background. I work on a simulink model that is very large, we have been working on it for years.To this day we still load all necessary variables in through the workspace.

This has been a complaint of mine for a long time, so much that mathworks has even addressed the issue by providing the Simulink. Save_vars function.It sounds like you are already setting up variables with a script/function, so Simulink. Save_vars won't be much use to you.

You can clean up the workspace by using structures for some of the variables, most simulink blocks don't support structures, but some do. Also, avoid putting anything in the workspace other than variables that your model needs.

Really?! Aw... puke. –?

_? Mar 12 '11 at 0:34 -1 because I've done it. – Jason S Mar 12 '11 at 15:04.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions