I wrote a script where I update a certain parameter but I need to pass it to the initialization tab otherwise it gives me error where I should initialize it and of course this conflicts with written script for parameter sweeping.
The script is shown below:
values = linspace(0, 0.5, 5); % Sweep R from 1Ω to 10Ω in 5 steps
results = zeros(size(values));
for i = 1:length(values)
b = values(i); % Set parameter value
y = 1-b;
end
Refer to the Simulation Scripts section of the PLECS Manual and the Buck Converter with Parameter Sweep demo model for an introduction to Simulation Scripts.
Note the use of a struct which contains the ModelVars
field in the plecs('simulate',opts)
command. Where opts = {'ModelVars' : { 'b' : values(i), 'y' = 1-values(i) } }
(as an example). From the PLECS Manual:
The optional field ModelVars is a struct variable that allows you to override variable values defined by the model initialization commands. Each field name is treated as a variable name; the field value is assigned to the corresponding variable. Values can be numerical scalars, vectors, matrices or 3d arrays or strings.
The override values are applied after the model initialization commands have been evaluated and before the component parameters are evaluated as shown in the figure below.