Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

Holding a Trace in the Scope

+2 votes

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?

asked Mar 12 by fdegioanni (25 points)
edited Mar 13 by fdegioanni

1 Answer

+3 votes
Best answer

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\n',
          inductorValues(ix), maxv, out.Time(maxidx));


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).



answered Mar 13 by Falk Kyburz (153 points)
selected Mar 13 by fdegioanni
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.


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.


Hi Falk,


Thanks! That is what I was needing.