Parameter sweep using simscape

16 Ansichten (letzte 30 Tage)
Joshua W R Meggitt
Joshua W R Meggitt am 8 Jan. 2021
I am trying to use Simscape to model the simple cross-over filter below.
Using the linearisation tool box I am able to extract its state-space representation and plot its transfer function. I would like to run a parameter sweep where I vary the inductance of Ind1.
I have managed to get this working, but the simulation has to recompile everytime it is linearised. When I use the fastRestartForLinearAnalysis( ) function (taken fropm the example in https://uk.mathworks.com/help/slcontrol/ug/fastrestartforlinearanalysis.html) the model no longer recompiles with each iteration, but the variable L_LP doesnt seem to get updated anymore... How can I avoid recompiling the model everytime, whilst still varying parameter values?
The main peice of code I am using is given below.
set_param('test1/Ind1','L','L_LP');
L_LP = 1e-3;
% fastRestartForLinearAnalysis(mdl,'on')
for n = 1:100
L_LP = L_LP + 0.0001 ; % Value of an inductor in circuit
% Simulink.Block.eval('test1/Ind1')
linsys = linearize(mdl,io);
[magLP(n,:), phaseLP(n,:)] = bode(linsys(1),w);
end
% fastRestartForLinearAnalysis(mdl,'off');

Antworten (1)

Juan Sagarduy
Juan Sagarduy am 12 Jan. 2021
Hi Joshua
Is the inductance parameter set as Run-time in the Simscape component? By default it is not, so maybe you can check this and test out.
https://se.mathworks.com/help/physmod/simscape/run-time-parameters.html
Regards / Juan
  1 Kommentar
Joshua W R Meggitt
Joshua W R Meggitt am 12 Jan. 2021
Hi Juan,
Thanks for the suggestion. I wasnt aware of run-time parameters in simscape, they certainty look relevent.
Unfortuantely, after setting the inductance parameter to run-time, I am having the same issue. With each iteration the inductance variable updates in the workspace, but when I linearise the model nothing seems to change. Where as if i recompile between lineartisations I get the expected spread of bode plots.
Any other suggestions would be welcome!
BR
Josh

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Electrical Sensors finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by