% This is an example script that creates workspace variables for a
% Simulink model. This is used to demonstrate how parameter loading
% can be quite slow for large Simulink models. It should take 4-5 seconds
% to run this code - less time than many large models' parameter scripts,
% but this is used to demonstrate the benefits of caching to MAT format.
% Copyright 2007 - 2009 The MathWorks, Inc.
% Display a message
disp(['Running initialization script: ' mfilename]);
% Create a bunch of Workspace Variables
for i=1:500
iStr = int2str(i);
eval(['DemoVariable' iStr '=' iStr ';']);
end
% Create a bunch of Parameter Objects
for i=1:500
iStr = int2str(i);
eval(['DemoParameterObject' iStr '= Simulink.Parameter;']);
eval(['DemoParameterObject' iStr '.value =' iStr ';']);
end
% Create a bunch of Signal Objects
for i=1:500
iStr = int2str(i);
eval(['DemoParameterObject' iStr '= Simulink.Signal;']);
end
% Create a bunch of Bus Objects
for i=1:500
iStr = int2str(i);
cellInfo = { ...
{ ...
['BusObject' iStr], { ...
{'Element1', 1, 'double', -1, 'real', 'Sample'}; ...
{'Element2', 1, 'double', -1, 'real', 'Sample'}; ...
{'Element3', 1, 'double', -1, 'real', 'Sample'}; ...
{'Element4', 1, 'double', -1, 'real', 'Sample'}; ...
{'Element5', 1, 'double', -1, 'real', 'Sample'}; ...
{'Element6', 1, 'double', -1, 'real', 'Sample'}; ...
} ...
} ...
};
Simulink.Bus.cellToObject(cellInfo);
end