Hello,
I am trying to perform different parameter sweeps using the simulation scripts. I have been able to change the parameters and running different simulations. However, when I want to use the analysis tools (For instance AC sweep or Multi tone), I am not able to define the path for the scope, and I cannot hold the traces for the analysis results. Is there any solution for this?
Thanks
2 Likes
Hello fdegioanni,
In the demo-models, look for âBuck converter with parameter sweepâ. There you find this in the simulation script:
% create simStruct with field 'ModelVars'
mdlVars = struct('varL', 50e-6);
simStruct = struct('ModelVars', mdlVars);
% clear all traces in scope 'Scope' in the current model
plecs('scope', './Scope', 'ClearTraces');
inductorValues = [50, 100, 200];
for ix = 1:length(inductorValues)
% set value for L1
simStruct.ModelVars.varL=inductorValues(ix) * 1e-6;
% start simulation, return probed signal values in 'out'
out = plecs('simulate', simStruct);
% hold and label trace
plecs('scope', './Scope', 'HoldTrace', ['L=' mat2str(inductorValues(ix)) 'ÎźH']);
% find maximum current value and index
[maxv, maxidx] = max(out.Values(1,:));
% Output maximum current values to Octave console
printf('Max current for L=%dÎźH: %fA at %fs
',
inductorValues(ix), maxv, out.Time(maxidx));
end
Where this example uses â./Scopeâ, use the name of your particular scope, for example â./MyScopeâ.
If your scope is an a subsystem, the path must be adapted accordingly, for example â./MySubsystem/MyScopeâ.
The path uses unix-like syntax, where the dot refers to the current location (or current model, in this context).
Hi Falk,
Thanks for your answer.
You are right, that is the way. I have implemented that and it works fine. However, it only works with the scopes that you place in the schematic.
When you use the analysis tools (for example Multitone), it opens a new scope with the frequency response of the system. The name of the scope is the same than the name of the analysis. However if you try to use â./NameOfAnalysisScopeâ, it doesnât work.
I have tried to implemented the same in the Simulink blockset, but I cannot make the multitone analysis works.
Thanks
Sorry for the off-topic answer!
The documentation in section âSimulation Scriptsâ states:
[âŚ] The scopePath is the path to the scope within the model including the model name, e.g. âDTC/Mechanicalâ. To access Bode plots from the analysis tools, use the model name followed by â/Analyses/â followed by the name of the analysis, e.g. âBuckOpenLoop/Analyses/Control to Output TF (AC Sweep)â. A leading dot (.) in the scope path is substituted with the current component or model as described in âPath Substitutionâ below. [âŚ]
Here you go.
Cheers
Falk
Hi Falk,
Thanks! That is what I was needing.
Franco