Clear Filters
Clear Filters

Using srcWorkspace with Data Dictionaries

4 views (last 30 days)
Jared Augsburger
Jared Augsburger on 15 Nov 2017
Answered: Tamas Rozsa on 7 Jan 2022
I'm attempting to upgrade an existing model to use Data Dictionaries. Currently, the code calling the model places external input data into a functions workspace and then executes a sim command using the parameter ('srcWorkspace','caller'). Once I attach to a data dictionary, it appears as though Simulink is ignoring the srcWorkspace setting and only using the base workspace to attempt to find variables.
Was wondering if anybody knows if this is intended behavior with Data dictionaries, or if there is a way to use Data dictionaries and define my input data inside a function. I'm using Matlab R2016b

Answers (1)

Tamas Rozsa
Tamas Rozsa on 7 Jan 2022
I've experienced a very similar incorrect behavior with R2020a Update 7, too.
MathWorks confirmed that this is a bug. 'SrcWorkspace' should work properly with data dictionaries as well.
Another way and a possible workaround to feed the model with temporary data is utilizing Simulink.SimulationInput class (permanent data shall be stored in data dictionaries). Details for R2020a can be found here: https://www.mathworks.com/help/releases/R2020a/simulink/slref/simulink.simulationinput-class.html
According to the tech support, "this workflow is the recommended workflow to apply variable overrides, as the SimulationInput object provides better containerization, traceability, and reuse across workflows".
Unfortunately, this has been introduced only in R2017b, i.e. it was not yet available in R2016b.

Products

Community Treasure Hunt

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

Start Hunting!