This example shows an implementation of a linear passive bandpass-filter. The filter has an approximate center frequency of 100MHz and a bandwidth of 15MHz to show how to perform small-signal frequency-domain analysis using Simulink® and MATLAB®. Other products available for performing this analysis on Simscape™ Electronics™ models are Control System Toolbox™ and Simulink Control Design™. These two products provide predefined functions to manipulate and analyze nonlinear models using GUIs or a command line approach.
To perform a small-signal frequency analysis, construct a linearized state-space model using the Simulink
linmod command. You must specify input and output ports with Simulink Inport and Outport blocks before invoking the
linmod command. In this example, the Inport and Outport blocks connect to the filter using a controlled voltage source (CVS), a Simulink-PS Converter and a PS-Simulink Converter.
If Simulink Control Design is available you can use either the
linearize function or the Linearization Task node of the GUI. Using the GUI approach you specify input and output ports by right-clicking on the Simulink lines corresponding to these ports and selecting the appropriate point under Linearization Points. Once you do this, these Linearization Points are visible in the model. In this model the Linearization Points are found at the output of the Simulink Inport block and the output of the PS-Simulink Converter block.
Linearize the model using the
linmod computes the linear state-space model by linearizing each block in the model individually. The return value of
linmod is a state-space representation, but
linmod can transform its output to a transfer function or a MATLAB data structure representation depending on how left-hand side of the equation is specified. To return a linearized model in state space form where the extra states associated with blocks that have no path from input to output have been removed, use the following command:
[A, B, C, D] = linmod('elec_ss_analysis',,,[1e-5 0 1]);
Bode plots display the magnitude and phase response of a linearized model. Other commonly used analyses for linear systems are step, impulse or Nyquist. These analysis methods, as well as others, are predefined in Control System Toolbox and Simulink Control Design, but can be coded when the above products are not available. The following code creates and displays a Bode plot for a continuous-time system linearized by
linmod using the state space representation. Bode computes the system frequency response H(s) on the imaginary axis, s = j*omega. The frequency response for the state representation is
Specify frequency points
FreqPts = logspace(-4,10,1401); s = 1j*2*pi*FreqPts; % State space response calculation ss_resp = zeros(1,length(s)); I_mat = eye(length(A)); for idx=1:length(s) ss_resp(idx) = D + C * ( (s(idx)*I_mat-A) \ B); end % Plot the response subplot(2,1,1); semilogx(FreqPts, 20*log10(abs(ss_resp))); title('Bode plot'); xlim([1e-4 1e10]);xlabel('Frequency (rad/s)');ylabel('Magnitude (dB)') subplot(2,1,2); semilogx(FreqPts,(2*pi+unwrap(angle(ss_resp)))*180/pi); xlim([1e-4 1e10]);xlabel('Frequency (rad/s)');ylabel('Phase (degrees)')
You can describe the bandpass filter in this example using a transfer function representation. However, the state-space representation is preferable over the transfer function form because it reduces the size of numerical noise errors. The Control System Toolbox documentation section called Choice of LTI Model discusses the computational reliability of different types of models. This documentation explains how response algorithms, like the Bode calculation above, in Control System Toolbox are enhanced to improve numerical reliability and stability.