slLinearizer & parameter variation in Simscape

2 views (last 30 days)
Hello,
I want to do a batch linearisation using slLinearizer on a Simulink model that contain Simscape components.
The linearisation is actualy working, but with for loops and iterations over vectors. That's slow.
The changing parameters coupling & primary_ind are inside of a simscape block :
I can create the batch linearisation interface :
io = getlinio(projectName);
sllin = slLinearizer(projectName,io);
I can create and specify the parameters :
coupling_mat = linspace(a,b,c);
primary_ind_mat = logspace(a,b,c);
[I,C] = ndgrid(primary_ind_mat,coupling_mat);
params(1).Name = 'primary_ind'; % i want here to link the simscape block upside
params(1).Value = I;
params(2).Name = 'coupling'; % same here
params(2).Value = C;
But when i try to update the parameters :
sllin.Parameters = params;
I get this error :
Error using slLinearizer/set.Parameters (line 324)
The expression "input(1).Name", "primary_ind" does
not successfully evaluate in model or base
workspace.
Caused by:
Error using sdo.getValueFromModel (line 94)
The variable 'primary_ind' cannot be resolved by
the model 'teslar2019a'. Make sure that the
variable is defined in the model, base
workspace, or data dictionary.
But as you can see on the first pic, there is a parameter called "primary_ind" in the model, inside a simscape block.
I've read :
I don't get how to link the parameters to the simulink model.
Thank you !

Answers (1)

Danvir Sethi
Danvir Sethi on 5 Aug 2019
Where are the variables 'primary_ind', 'secondary_ind', and 'coupling' which are being referenced by the Simscape blocks defined? Are they defined in a mask workspace, model workspace, base workspace or none of these? Are you able to simulate the model as is?
I think you need a couple of things:
  1. Create 'primary_ind', 'secondary_ind', and 'coupling' variables which are being referenced by the Simscape blocks in either the base or model workspace. The default values can be specified for these variables in one of these workspaces, which would be overridden by the linearization workflow.
  2. Due to the known issue (https://www.mathworks.com/support/bugreports/details/2001393), please use:
opt = linearizeOptions;
opt.AreParamsTunable = false;
sllin = slLinearizer(projectName,io, options);

Community Treasure Hunt

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

Start Hunting!

Translated by