MATLAB Answers

How to make the value in Data Store Memory global

2 ビュー (過去 30 日間)
Kristian Shyti
Kristian Shyti 2021 年 8 月 6 日
回答済み: Fangjun Jiang 2021 年 8 月 6 日
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?

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2021 年 8 月 6 日
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