I've made a model with a script to plot mulltiple trace in an ac analisys fro different value of an iunductor
ti works fine but it does not delete the previous trace on the scope, folloving the script and attached the PLECS model someone can show me where is the mistake?
second question how to modify the script to add grids on the graph?
% create simStruct with field 'ModelVars'
mdlVars = struct('varL', 5e-6);
simStruct = struct('ModelVars', mdlVars);
plecs('scope', './Scope', 'ClearTraces');
% parametric values to be swept
inductorValues = [2, 4, 6, 8, 10, 15]; % in uH
legendValues = {};
for ix = 1:length(inductorValues)
% set value for L1
simStruct.ModelVars.varL = inductorValues(ix) * 1e-6;
simResult=plecs('analyze', 'AC Sweep', simStruct)
plecs('scope', './Analyses/AC Sweep', 'ClearTraces');
legendStr = ['L=' mat2str(inductorValues(ix)) 'uH'];
legendValues(ix) = legendStr;
% start simulation, return probed signal values to workspace using Output port '1'
% hold and label traces in Scope
plecs('scope', './Analyses/AC Sweep', 'HoldTrace')
subplot(2,1,1);
semilogx(simResult.F,abs(simResult.Gr+1i*simResult.Gi));
hold on;
subplot(2,1,2);
semilogx(simResult.F,angle(simResult.Gr+1i*simResult.Gi)*180/pi);
hold on;
end
% Label plots
subplot(2,1,1);
title('Example of Bode Plot with Linear Magnitude');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
legend(legendValues);
subplot(2,1,2);
xlabel('Frequency (Hz)');
ylabel('Phase (deg)');
legend(legendValues);