Frequency Response of Passive Circuit
This demonstration shows how to generate the frequency response of a non-switched network. In this example, a Bode plot is produced for a first-order RC network. In addition, a Simulation Script is included where a parameter sweep can be executed for various values of the passive components.
The script requires a value for the resistance and a cutoff frequency for the filter network. The capacitance is then calculated for each combination and an AC Sweep Analysis is performed. The frequency response result of each simulation is displayed as a new trace in the plot window.
% parameter definitions, create simStruct with field 'ModelVars' mdlVars = struct('R', 1, 'C', 100e-6, 'fc', 10e3); simStruct = struct('ModelVars', mdlVars); % clear all traces in frequency response plot window in the current model plecs('scope', 'RCFreqResp/Analyses/AC Sweep', 'ClearTraces'); fcValues = [10e2, 10e3, 10e4]; % cutoff frequencies for ix = 1:length(fcValues) fc = 10e3; % RC filter cutoff frequency simStruct.ModelVars.C = 1/(2*pi*simStruct.ModelVars.R*fcValues(ix)); % RC filter capacitance plecs('analyze', 'AC Sweep', simStruct); % start AC Sweep analysis plecs('scope', 'RCFreqResp/Analyses/AC Sweep', 'HoldTrace', ['fc=' mat2str(fcValues(ix)/1000) 'kHz']); % hold and label trace end
To run the scripted simulation demonstration, select Simulation scripts... from the Simulation menu and run the Filter Frequency Response Sweep script. Note that an existing AC Sweep Analysis is required to run the script and one has already been setup for this model. Additionally, the Analysis Tools window should be open prior to executing the script (select Analysis Tools... from the Simulation menu) in order to view the resulting plots. Also note that the `Operating point' analysis setting is set to `non-periodic (DC)' as the system contains no switches or discrete blocks. An alternative option is to use a `System period' of 0, which is equivalent to defining the system as non-periodic.