%% Arrays for Parameters

% Copyright 2020 The MathWorks, Inc.

%% C Construct
% |float myParams[5]= {1.0F,2.0F,3.0F,4.0F,5.0F};|

%% Procedure
% 1. Create the <matlab:ex_param_array |ex_param_array|> model by using a Gain block.
open_system('ex_param_array');

%%
% 2. In the model, select the Gain block. In the Property Inspector, set 
%    the value of the *Gain* parameter to |myParam|.
%
% 3. Next to the parameter value, click the action button (the button with 
%    three vertical dots) and select *Create*.
myParam = Simulink.Parameter([1 2 3 4 5]);
set_param('ex_param_array/Gain','Gain','myParam');

%%
% 4. In the Create New Data dialog box, set *Value* to |Simulink.Parameter
%    ([1 2 3 4 5])|. Click *Create*.
%    A |Simulink.Parameter| object, |myParam|, appears in the base workspace. 
%    The Gain block uses the object to set the value of the Gain parameter. 
%
% 5. In the |Simulink.Parameter| property dialog box, set *Storage class* to 
%    |ExportedGlobal|. Click OK.
myParam.StorageClass = 'ExportedGlobal';

%%
% With this setting, |myParams| appears in the generated code as a separate 
% global variable.
%
% 6. Set *Data type* to |single|. Click *OK*.
myParam.DataType = 'single';
%%
% 7. To build the model and generate code, press *Ctrl+B* .
evalc('rtwbuild(''ex_param_array'')');

%% Results
% The generated source file |ex_param_array.c| defines and initializes the 
% global variable |myParams|.
file = fullfile('ex_param_array_ert_rtw','ex_param_array.c');
rtwdemodbtype(file,'/* Exported block parameters */', ...
    '/* External inputs (root inport signals with default storage) */',1,1);










