- In the Ports and Data Manager, you may need to manually create the data entry and change the name to match the Data Store Memory block, and set the scope to Data Store Memory.
- You will need to specify Dimensions, Signal type (real/complex), and Data type (e.g. double) for the variable in the corresponding Data Store Memory block.
- The initial value will be determined by the Initial value setting given in the Data Store Memory block. Variables of the same name in for example the Base Workspace are ignored.
Why do I get an error using global variables in my MATLAB Function block?
15 views (last 30 days)
Show older comments
MathWorks Support Team
on 29 Apr 2019
Edited: MathWorks Support Team
on 24 Sep 2025 at 17:45
Why do I get the below error upon using global variables in my MATLAB Function block?
Global declaration not resolved to Data Store Memory using global variables in my MATLAB Function block
Accepted Answer
MathWorks Support Team
on 5 Sep 2025 at 0:00
Edited: MathWorks Support Team
on 24 Sep 2025 at 17:45
The Diagnostic Viewer may say something like "Global declaration not resolved to a Data Store Memory block registered via the Ports and Data Manager.", or "Global declaration not resolved to a Data Store Memory block registered with the symbols pane".
In MATLAB Functions in Simulink, global declarations are not mapped to the MATLAB global workspace. To use global data in your MATLAB Function block, or in any code that this block calls, you must:
Step 1: Declare a global variable in your MATLAB Function block script, or in any code that is called by the MATLAB Function block,
Step 2: Initialize a variable with the same name with scope "Data Store Memory" within the symbols pane for that MATLAB Function block.
Step 3: Register a Data Store Memory block or Simulink.Signal object associated with this variable.
For Step 3, whether you choose a Data Store Memory block or a Simulink.Signal depends on whether you want to use a large number of Data Stores and whether you need to access the data across multiple models. For more information, refer to the
.
That page also provides links to the exact steps that you need to take to carry out both Step 1 and Step 2 above for each application. For example: Access Data in Data Store Memory Blocks by Using MATLAB Function Blocks - MATLAB & Simulink.
If you are using the Data Store Memory block approach, please note the following:
0 Comments
More Answers (0)
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!