MATLAB: Libraries, model workspace, base workspace and how to parameterize the models

parameterization

Hello everybody,
I am building a library (with sublibraries) of models that will eventually be used as parts in simulations of industrial equipment.
Although it is not exactly this way, let us consider this hierarchy:
Library/
* Motors/
* -- Diesel_A31
* -- Diesel_A32
* Powertrains/
* -- PT03
* -- PT10
Now the question is that every model should be able to run independently, but all the models make use of constants such as for example:
  • Gravity (both for motors and powertrains)
  • Themodynamical properties from air in normal conditions (only for motors, nor for Powertrains)
and parameters, like:
  • Air temperature (both for motors and powertrains the same), would be a "whole simulation" parameter
  • Horsepower (only for motors, for every motor potentially different, for every instance of the model the same)
  • Initial position of the cilinder (only for motors, for every instance different)
Now the question is how do I manage and store all this information in the library and the models that reside inside each library or sub-library.
  • Global workspace? Please no
  • Model workspace? It looks like my models haven't got a model workspace, maybe since they are in a library
  • Mask parameters? I would rather be able to write them down in a text file where I could explain the meaning of each parameter. The number of parameters is too high anyway. I think that the initial position of the cilinder could be a mask parameter.
And would it be possible to make the parameters accesible to the model without the user actually intervining? I try to keep in mind that the model should be able to work independently without the user having to look under the mask or perform any action.
Even though the problem is not very clear either to me, I hope I was able to state the question clearly.
Any help or experience in this regard would be greatly appreciated.
Carlos.

Best Answer

Hi Carlos,
Is there any specific reason you have decided on using libraries for this? It sounds like you'd have a much easier time using model references.
With model references, each component (Diesel_A31, Diesel_A32, PT03, etc.) would be it's own separate model. This means each component would
  • Have its own Model Workspace where you could store local data
  • Be capable of running as a standalone simulation
If you use subsystems stored in libraries for these components, then the only local workspace those subsystems have for parameters is the Mask Workspace.
What's very nice about the Model Workspace over the Mask Workspace is that you can define either a MAT-file or a MATLAB script as the data source for the Model Workspace. So, you could write all your parameters for a given component in a MATLAB script and then tell the Model Workspace to use that MATLAB script as its data source.
Does that make sense?