MATLAB Answers

How to make the value in Data Store Memory global

2 views (last 30 days)
Kristian Shyti
Kristian Shyti on 6 Aug 2021
Answered: Fangjun Jiang on 6 Aug 2021
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;
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
Fangjun Jiang on 6 Aug 2021
Most likely, step 3 is missed.
3. Make sure the global variable is registered to the MATLAB Function block

Community Treasure Hunt

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

Start Hunting!

Translated by