DOC PREVIEW
CSUN ECE 351 - Solving State Variable Equations for Discrete Time Systems

This preview shows page 1-2 out of 5 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

ECE 351 – Linear Systems II MATLAB Tutorial #6 Solving State Variable Equations for Discrete Time Systems This tutorial will discuss the use of MATLAB in the solution of state variable equations. The methods described here only use MATLAB commands that are available in basic MATLAB and in the Signal Processing Toolbox. However, it is important to note that the Control Systems Toolbox that is available for MATLAB contains many other commands that are particularly powerful for solving state variable equations. The Control Systems Toolbox is typically introduced in a control systems course. Figure 1. Discrete Time System The system shown above is an example of a single-input, single-output discrete time system. In class, it was shown to have a state variable representation with matrices: A =2 02 1!"#$%& B =11!"#$%& C = 0 2[ ] D = 0 Impulse Response of Discrete Time Systems The impulse response of a discrete time system can be found from the state variable equations using: € hk=D;k = 0CAk−1B;k ≥1$ % & unitdelay2xkyk++unitdelay++22+The following MATLAB commands use this formula to find the values of hk for 0 ≤ k ≤ 6 and to plot them along with the expression for hk found in class (hk= 2 2k− 1"#$%uk). Note that they are the same. >> clear >> A=[2 0; 2 1]; >> B=[1; 1]; >> C=[0 2]; >> D=[0]; >> k=0:6; >> h0=D; >> for n =1:6 h(n)=C*(A^(n-1))*B; end >> htheor=2*(2.^k-1).*(k>=0); >> h=[h0,h]; >> subplot(2,1,1) >> stem(k,h) >> subplot(2,1,2) >> stem(k,htheor) Figure 2. Impulse Response of Discrete Time System Another method for determining the impulse response is to use simulink. Open a Simulink model and create the model shown below in figure 3.Figure 3. Simulink Model In order to determine the impulse response in Simulink we need to apply an impulse at the input of this system. This can be accomplished by entering the following command in the command window: >> imp=[1,zeros(1,6)]; Set the simin source to apply [k’, imp’] as the input with a sample time of 1 and set the simout source to create an array of output data. After running this simulation plot the output and compare it to the output shown in figure 2. If you are having trouble with Simulink refer to MATLAB Tutorial #5. You should observe the same impulse response sequence as that shown in figure 2. In MATLAB Tutorial #2 we discussed the use of the filter command to produce a system output from the vectors of coefficients [b, a] associated with the linear difference equation for a discrete time system. In MATLAB Tutorial #4 the filter command was used to find the impulse response. This method for finding the impulse response can only be used if the coefficient vectors b and a are known. The MATLAB command ss2tf finds the a and b coefficients, and hence the linear difference equation for a system from the state variable description. The following MATLAB commands will produce the impulse response in this way. >> [b,a]=ss2tf(A,B,C,D,1); >> htf=filter(b,a,imp); The first command uses ss2tf to find the b and a coefficient vectors. These vectors are then applied to the filter command along with the impulse input to produce htf, the impulse response. Verify that the output sequence htf is in fact equivalent to the impulse response functions found using the other methods.Frequency Response of Discrete Time Systems As shown in MATLAB Tutorial #3, the frequency response function, H, can be found using the freqz command. Like the filter command, freqz also requires the coefficient vectors, a and b. The following MATLAB commands can be used to plot the amplitude and phase spectrum of a discrete time system from the state variable vectors: >> [b,a]=ss2tf(A,B,C,D,1); >> [H, theta] = freqz(b,a); >> subplot(2,1,1) >> plot(theta, abs(H)) >> subplot(2,1,2) >> plot(theta, angle(H)) Figure 4. Amplitude and Phase Spectrum of DTS Stability of Discrete Time Systems The stability of a discrete time system can be determined by finding the eigenvalues of the A matrix in the state variable description of the system. The MATLAB command, eig, finds the eigenvalues of any square matrix. The following MATLAB command find the eigenvalues of the matrix A given above and places them in a vector, r. >> r=eig(A) resulting in the output:r = 1 2 Since at least one of the eigenvalues (in this case both) has a magnitude greater than or equal to one we know that the system is unstable. Based on the impulse response sequence found about this is not a


View Full Document

CSUN ECE 351 - Solving State Variable Equations for Discrete Time Systems

Documents in this Course
Load more
Download Solving State Variable Equations for Discrete Time Systems
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Solving State Variable Equations for Discrete Time Systems and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Solving State Variable Equations for Discrete Time Systems 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?