0% found this document useful (0 votes)
24 views6 pages

Control Systems Lab Exercises at DOE CUSAT

This document provides instructions and exercises for two lab experiments in control systems using MATLAB: 1) Experiment 1 focuses on familiarizing with MATLAB commands through exercises involving matrix manipulation, plotting functions, and generating random matrices. 2) Experiment 2 demonstrates various polynomial operations in MATLAB like representing and evaluating polynomials, finding roots, differentiation, convolution/deconvolution, and partial fraction expansion. Exercise problems are provided to have students practice these operations.

Uploaded by

Muhammed Razi M
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views6 pages

Control Systems Lab Exercises at DOE CUSAT

This document provides instructions and exercises for two lab experiments in control systems using MATLAB: 1) Experiment 1 focuses on familiarizing with MATLAB commands through exercises involving matrix manipulation, plotting functions, and generating random matrices. 2) Experiment 2 demonstrates various polynomial operations in MATLAB like representing and evaluating polynomials, finding roots, differentiation, convolution/deconvolution, and partial fraction expansion. Exercise problems are provided to have students practice these operations.

Uploaded by

Muhammed Razi M
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

20-305-0206: Control Systems Lab Exercises

Dr. Nalesh S
Assistant Professor

The Lab Exercises and manual are adopted from


Linear Control Systems Laboratory Manual for the course CISE302 prepared by
Systems Engineering Department
King Fahd University of Petroleum and Minerals

The Exercises are meant for Control System Lab (20-305-0206) for MSc 2nd Semester
at DOE, CUSAT
Experiment1: Familiarizing with Matlab (Week1)

Exercise 1:
Use Matlab command to obtain the following
a) Extract the fourth row of the matrix generated by magic(6)
b) Show the results of ‘x’ multiply by ‘y’ and ‘y’ divides by ‘x’.
Given x = [0:0.1:1.1] and y = [10:21]
c) Generate random matrix ‘r’ of size 4 by 5 with numbers varying between -8 and 9. Multiply this
matrix with a 5 by 5 magic square matrix. Print the 3rd row of the result.

Exercise2:
Use MATLAB commands to get exactly as the figure shown below
x=pi/2:pi/10:2*pi; y=sin(x); z=cos(x);
Experiment2: Polynomials in Matlab (Week1)

Representing Polynomials
MATLAB represents polynomials as row vectors containing coefficients ordered by descending
powers. For example, consider the equation

This is the celebrated example Wallis used when he first represented Newton's method to the French
Academy. To enter this polynomial into MATLAB, use
>>p = [1 0 -2 -5];

Polynomial Roots
The roots function calculates the roots of a polynomial:
>>r = roots(p)

r=
2.0946
-1.0473 + 1.1359i
-1.0473 - 1.1359i

By convention, MATLAB stores roots in column vectors. The function poly returns to the polynomial
coefficients:
>>p2 = poly(r)
p2 = 1 8.8818e-16 -2 -5

poly and roots are inverse functions

Polynomial Evaluation
The polyval function evaluates a polynomial at a specified value. To evaluate p at s = 5, use
>>polyval(p,5)
ans = 110
It is also possible to evaluate a polynomial in a matrix sense. In this case the equation
becomes , where X is a square matrix and I is the identity
matrix.
For example, create a square matrix X and evaluate the polynomial p at X:
>>X = [2 4 5; -1 0 3; 7 1 5];
>>Y = polyvalm(p,X)
Y=
377 179 439
111 81 136
490 253 639
Convolution and Deconvolution
Polynomial multiplication and division correspond to the operations convolution and deconvolution.
The functions conv and deconv implement these operations. Consider the polynomials
and . To compute their product,
>>a = [1 2 3]; b = [4 5 6];
>>c = conv(a,b)
c = 4 13 28 27 18
Use deconvolution to divide back out of the product:
>>[q,r] = deconv(c,a)
q=4 5 6
r=00000
Polynomial Derivatives
The polyder function computes the derivative of any polynomial. To obtain the derivative of the
polynomial
>>p= [1 0 -2 -5]
>>q = polyder(p)
q = 3 0 -2
polyder also computes the derivative of the product or quotient of two polynomials. For example,
create two polynomials a and b:
>>a = [1 3 5];
>>b = [2 4 6];
Calculate the derivative of the product a*b by calling polyder with a single output argument:
>>c = polyder(a,b)
c = 8 30 56 38
Calculate the derivative of the quotient a/b by calling polyder with two output arguments:
>>[q,d] = polyder(a,b)
q = -2 -8 -2
d = 4 16 40 48 36
q/d is the result of the operation.

Partial Fraction Expansion


‘residue’ finds the partial fraction expansion of the ratio of two polynomials. This is particularly
useful for applications that represent systems in transfer function form. For polynomials b and a,

if there are no multiple roots, where r is a column vector of residues, p is a column vector of pole
locations, and k is a row vector of direct terms.
Consider the transfer function
>>b = [-4 8];
>>a = [1 6 8];
>>[r,p,k] = residue(b,a)

r = -12
8
p = -4
-2
k = []
Given three input arguments (r, p, and k), residue converts back to polynomial form:
>>[b2,a2] = residue(r,p,k)
b2 = -4 8
a2 = 1 6 8

Exercise 1:
Consider two polynomials p(s) = s2 + 4s + 4 and q(s) = s2 + 1. Using matlab compute
a. Product of p(s) and q(s)
b. Roots of p(s), q(s) and p(s)*q(s)
c. p(-2), p(0), q(3), q(-1).
Evaluate using pen and paper and compare the results.

Exercise 2:
Use Matlab to find the partial fraction equivalent of the following.
𝑨(𝒔) 𝒔+𝟑
a. 𝑩(𝒔) = 𝒔𝟑+𝟕𝒔𝟐+𝟏𝟎𝒔
𝑨(𝒔) 𝒔𝟐 +𝟓𝒔+𝟔
b. 𝑩(𝒔)
= (𝒔+𝟐)𝟑
𝑨(𝒔) 𝟒𝒔𝟐 +𝟐𝒔+𝟑
c. 𝑩(𝒔)
= 𝒔𝟑 +𝟐𝒔𝟐 +𝒔−𝟏𝟖

Common questions

Powered by AI

Using MATLAB's built-in functions for polynomial operations is critical due to their precision, efficiency, and ability to handle complex expressions that could be error-prone and cumbersome to solve manually. Functions like 'roots' simplify the process of finding polynomial roots accurately and quickly, ensuring consistency in results (e.g., r = roots(p)). Likewise, 'polyder' streamlines derivative calculations for polynomials and their products or quotients, which is essential for accurately modeling and simulating systems dynamics. These functions reduce computational burden, improve reliability of results, and are necessary for complex systems engineering problems .

MATLAB exercises deepen understanding of control systems by providing hands-on experience with complex mathematical concepts like polynomial roots, derivatives, and matrix operations. Exercises focus on practical application, requiring learners to solve real-world problems that model control systems behavior. They encourage exploration of MATLAB's tools for polynomial evaluations ('polyval'), derivatives ('polyder'), and roots ('roots'), fostering theoretical and practical integration. These exercises enhance computational proficiency and theoretical insight, crucial for mastering control systems engineering .

Polynomial multiplication in MATLAB is performed using convolution, a process that combines two sets of information. The 'conv' function is used for this operation, which computes the coefficients of the product of two polynomials (e.g., c = conv(a,b)). Conversely, deconvolution is used to separate the polynomial components using the 'deconv' function, which divides the polynomial back into its original factors (e.g., [q,r] = deconv(c,a)). This method effectively handles the inherent complexity of polynomial operations by breaking them down into simpler, more manageable parts .

Polynomial evaluation in MATLAB, facilitated by the 'polyval' and 'polyvalm' functions, allows determination of polynomial values at specific points or in a matrix context. The 'polyval' function evaluates a polynomial at a given scalar value (e.g., ans = polyval(p,5)), which is useful for analyzing polynomial curves. In contrast, 'polyvalm' evaluates polynomials when applied to matrices, delivering results relevant in systems and control scenarios (e.g., Y = polyvalm(p,X)). These functions enable detailed examination of polynomial behavior across individual points or broader matrices .

The 'polyder' function in MATLAB is crucial for computing the derivative of polynomials. It can calculate the derivative of a single polynomial (e.g., q = polyder(p)), or it can handle the derivative of products and quotients of two polynomials. When used with a single output argument for products, 'polyder' returns the derivative of the product (e.g., c = polyder(a,b)). For quotients, employing two output arguments provides both the numerator and denominator of the derivative (e.g., [q,d] = polyder(a,b)). This functionality is particularly useful for simplifying and analyzing complex polynomial expressions .

MATLAB represents polynomials as row vectors containing coefficients ordered by descending powers. The 'roots' function calculates the roots of a polynomial, returning them in a column vector (e.g., r = roots(p) for a polynomial p). The 'poly' function is the inverse, which returns polynomial coefficients given the roots (e.g., p2 = poly(r)). These functions allow for the determination of both polynomial roots and their reverse operations to obtain coefficients from roots .

MATLAB offers significant advantages for simulating control systems by providing robust computational tools that handle complex calculations efficiently, such as root solving, derivatives, and matrix operations. This environment excels in reducing time and error rates associated with traditional methods, which can be labor-intensive and error-prone. However, a potential limitation is that MATLAB may obscure the underlying mathematical processes, which could hinder deep theoretical understanding and oversight if over-relied upon. Therefore, while MATLAB enhances simulation speed and accuracy, complementary theoretical knowledge remains important for interpreting results .

The 'residue' function in MATLAB is designed to convert polynomials into their partial fraction expansions, offering insights into system behaviors particularly in system dynamics and control applications. When polynomials are expressed as ratios, 'residue' outputs a column vector of residues, a column vector of pole locations, and a row vector of direct terms (e.g., [r,p,k] = residue(b,a)). This decomposition helps in identifying the response characteristics of systems represented in transfer function form. It also allows conversion back to polynomial form using the residue components .

To multiply a random matrix with a magic square matrix in MATLAB, generate a random matrix of desired size within specified bounds (e.g., 'r' with values between -8 and 9 of size 4x5) and a magic square (e.g., magic(5)). Using matrix multiplication, calculate the product, then extract necessary rows or columns of the result as needed (e.g., the third row of the result). This operation models certain dynamic systems or tests stability due to the predictable properties of magic squares, which can simplify detection of errors or anomalies in matrix calculations within control systems .

MATLAB resolves control system problems involving polynomial equations through processes like convolution and deconvolution. For instance, given polynomials a and b, their convolution using 'conv' generates a product polynomial (e.g., c = conv(a,b)), which models system outputs. Conversely, 'deconv' breaks the product into its factors, aiding in understanding individual system components by providing quotients and remainders (e.g., [q,r] = deconv(c,a)). These processes are invaluable in control systems for tasks such as designing and analyzing stability and responses .

You might also like