Access to memory store via global in matlab function

Don't know how I managed this
Note how the second error report one simulation time step later exactly contradicts the first one from t=0.
I'm just using a matlab function to access a Simulink data store.
Here are the settings for it
Here is the code that raises the errors
% t is input from a clock block
% size(Screen)=[5 8]
function DOIT(t, Screen)
global CurrentSEPScreen;
if t==0 % Initialise - Shouldn't be necessary, but errors are raised
% Can't get rid of that error, trying different initialisation approaches.
Y=[32 32 32 32 32 32 32 32];
% CurrentSEPScreen(1,:)=Y;
% CurrentSEPScreen(2,:)=Y;
% CurrentSEPScreen(3,:)=Y;
% CurrentSEPScreen(4,:)=Y;
% CurrentSEPScreen(5,:)=Y;
CurrentSEPScreen=[Y;Y;Y;Y;Y];
else
for RowN=1:5
if any(Screen(RowN,:)~=CurrentSEPScreen(RowN,:))
CurrentSEPScreen(RowN,:)=Screen(RowN,:);
end
end
end
end

Antworten (1)

Fangjun Jiang
Fangjun Jiang am 24 Okt. 2018

0 Stimmen

I think the warning message is clear. If you want to ignore this, go to Simulation, Model Configuration Parameters, Diagnostics, Data Validity, Data Store Memory block, and change the setting.

6 Kommentare

John Carter
John Carter am 24 Okt. 2018
Bearbeitet: John Carter am 24 Okt. 2018
Thanks for looking at this
a) You didn't read the second warning message? ...the one that contradicts the first one.
b) what setting?
They are not contradicting. These write-after-write and read-before-write could all happen during the same simulation step. You can change the setting to ignore them.
John Carter
John Carter am 25 Okt. 2018
Bearbeitet: John Carter am 25 Okt. 2018
a) The first error occurs in the first simulation step at t=0 (as it states) - and the second error occurs in the second simulation step at t=0.05. b) what setting?
The setting regarding how to report these data store memory access abnormally, either "use local settings", "disable all", "enable all as warnings" or "enable all as errors".
John Carter
John Carter am 1 Nov. 2018
Bearbeitet: John Carter am 1 Nov. 2018
Yes, should have said "where are the settings" I guess.
They are here
John Carter
John Carter am 1 Nov. 2018
Bearbeitet: John Carter am 1 Nov. 2018
That is a work around not a fix, though I'll be using it for now.

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2018a

Gefragt:

am 24 Okt. 2018

Bearbeitet:

am 1 Nov. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by