From Workspace block using Data Dictionary

4 visualizaciones (últimos 30 días)
Thomas Kotwal
Thomas Kotwal el 6 de Nov. de 2018
Respondida: Thomas Kotwal el 12 de Nov. de 2018
How can I use a timeseries as a simulation input in a Simulink subsystem or model reference, when the model uses a Data Dictionary?
I tried using a 'From Workspace' block, which I think should be possible, since the documentation for the block has a section on Use with Data Dictionary. Here's what it says:
To access simulation input data, store the target variable in the base workspace and set the Data parameter by using a call to the evalin function. In the call to evalin, specify the ws argument as 'base' so that the block seeks the variable in the base workspace instead of the data dictionary. For example, if the name of the variable is myTimeseriesObject, set Data to evalin('base','myTimeseriesObject').
But, right after adding a 'From Workspace' block to my model a get a popup error message saying this:
This model cannot contain From Workspace block 'MyModelName/Input_Processing/From Workspace' because the model is linked to a data dictionary. For a test harness model, configure it to use the base workspace instead of a data dictionary. Otherwise, replace this block with a root Inport or other source block.
Thank you.

Respuesta aceptada

Thomas Kotwal
Thomas Kotwal el 12 de Nov. de 2018
I figured it out, or at least I figured out why it's not working with a From Workspace block. I'm using Simulink Release 2016b, and the ability to use a From Workspace block with a model that uses a data dictionary was added in Release 2017a.
See 2017a release notes for details:

Más respuestas (2)

Arunkumar M
Arunkumar M el 9 de Nov. de 2018
Even when model is linked to data dictionary, you can use evalin function to access variables which are defined in base workspace - refer attached image
-Other method is to create a referenced subsystem and pointing to the model which is linked to data dictionary and the reference subsystem can be linked to base workspace. Then the input from base workspace shall be propagated to the model linked to data dictionary

Thomas Kotwal
Thomas Kotwal el 9 de Nov. de 2018
Arunkumar, Are the source blocks in your image 'From Workspace' blocks? When I try to use a 'From Workspace' block in my model, I always get the error message that I mentioned in my original post, even when trying to use the evalin function in the Data field of the block.
  2 comentarios
Arunkumar M
Arunkumar M el 10 de Nov. de 2018
No They are constant blocks? Do you specifically want to use From Workspace blocks?
Thomas Kotwal
Thomas Kotwal el 12 de Nov. de 2018
What I'd like to do is access a timeseries object from within Simulink, but it doesn't necessarily need to be using a From Workspace block.
For now, I've got it working by saving the timeseries to a file and then accessing it using a From File block. That's ok, but it's a little cumbersome, and the documentation for the From Workspace block indicates that it shold work with From Workspace.
I'd be fine with saving the timeseries to the Data Dictionary and accessing it from there, but I'm not sure how to do that.
By the way, I was able to replicate your example for accessing a constant. It's not what I need right now, but might be useful later. Thanks.

Iniciar sesión para comentar.

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Productos


Versión

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by