How to make the value in Data Store Memory global
Show older comments
I have a simulink model that generates signals, I want to store the signal using data store write and data store memory (those are linked together), then I want to be able to use the stored signal (an array) as a global variable in MATLAB.
When I try to make the variable global in matlab nothing happens. Even after I start the simulation
global Signal_full_og; % the variable I want to make global
sig_arr = [];
sim simF.slx;
for vref 1:1:5 % first few signals will get generated with different vrefs in the model
sig_arr(index, :) = Signal_full_og;
end
Below there is a picture of the Data Store Write and Data Store Memory from my Simulink model

And below there is a picture of the block parameters of Data Store Memory

I have tried to follow the documentation from Mathworks and still I can't get a global variable. Does anyone spot any mistakes in this way or is there a better way to do the same thing?
Answers (1)
Fangjun Jiang
on 6 Aug 2021
1 vote
The example is here. https://www.mathworks.com/help/simulink/ug/using-global-data-with-the-matlab-function-block.html
Most likely, step 3 is missed.
3. Make sure the global variable is registered to the MATLAB Function block
Categories
Find more on Sources 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!