Professional Documents
Culture Documents
Name
Semester Fall Spring 20__
Roll No
Batch
2. To explore the MATLAB data objects: matrices, arrays, vectors and sets and
operations applicable on these objects
6. To learn to use MATLAB to (1) generate transfer functions, (2) manipulate transfer
functions, (3) identifying poles and zeros of transfer functions (4) plotting poles
and zeros of transfer functions (5) To study model conversion techniques
8. Learning simulation of linear systems with Unit Step and Impulse Inputs
10. To learn commands in MATLAB that would be used to reduce linear systems
block diagram using series, parallel and feedback configuration.
11. To study the performance characteristics of First order systems using MATLAB
12. To study the performance characteristics of Second order systems using MATLAB
COMMITMENT CHART
Week No. of
Date Object Sign
No Sessions
1. Introduction to the MATLAB environment and basic arithmetic
calculations.
Grade Allocation
Rubric
A B C D
Demonstrates a
Demonstrates a Demonstrates Demonstrates
Contextualize Problem: comprehensive
clear some no
and insightful
Ability to understand the understanding understanding understanding
understanding
problem within a larger of how the of how the of how the
of how the
context (problem within a problem fits problem fits problem fits
problem fits
problem). within the within the within the
within the
larger context. larger context. larger context.
larger context.
Demonstrates a
skillful ability Demonstrates
to identify Demonstrates some ability to Demonstrates
multiple an ability to identify a minimal or no
Formulate Strategies for strategies for identify an strategy for ability to
generating appropriate generating an identify a
Solving a Problem:
approaches to strategy for approach for strategy for
Ability to identify strategies solve a generating solving the generating an
for solving problems problem, and approaches for problem. approach for
has insight into solving a Strategy may or solving a
the pros and problem. may not be problem.
cons of those appropriate.
strategies
Demonstrates a Demonstrates
Demonstrates Demonstrates
skillful ability minimal or no
an ability to some ability to
to analysis, ability to
Analyze, Evaluate and Select analyze, analyze,
evaluate and analyze,
evaluate and evaluate and
Solutions: select evaluate or
select select
optimal/practic select
Ability to analyze, evaluate optimal/practic optimal/practic
al solution. optimal/practic
and select optimal/practical al solution. al solution.
Thorough and al solution.
solution, including feasibility Clear Partial
insightful Little or no
and impact. explanation of explanation of
explanation of explanation of
feasibility and feasibility and
feasibility and feasibility and
impact. impact.
impact. impact.
Implement Solutions: Demonstrates a Demonstrates Demonstrates Demonstrates
skillful ability an ability to some ability to minimal or no
ability to
Ability to implement a to implement a implement a implement a
implement a
practical solution to address practical practical practical
practical
the problem. solution solution. solution.
solution.
In the subsequent labs, we will introduce the MATLAB environment. We will learn:
1. How to create, edit, save, run, and debug m-files (ASCII files with series of MATLAB statements).
2. How to create arrays (matrices and vectors), and explore the built-in MATLAB linear algebra
functions for matrix and vector multiplication, dot and cross products, transpose, determinants, and
inverses, and for the solution of linear equations.
3. How to program logic constructs and loops in MATLAB,
4. How to use subprograms and functions,
5. How to use comments (%) for explaining the programs and tabs for easy readability, and
6. How to print and plot graphics both two and three dimensional.
7. Additionally, we will explore MATLAB’s functions for symbolic mathematics and the use of these
functions to perform symbolic operations, to develop closed form expressions for solutions to
algebraic equations, ordinary differential equations, and system of equations was presented.
Symbolic mathematics can also be used to determine analytical expressions for the derivative and
integral of an expression.
1.1.6 Abort
In order to abort a command in MATLAB, hold down the control key and press c to generate a local
abort with MATLAB.
1.1.8 Typing %
When percent symbol (%) is typed in the beginning of a line, the line is designated as a comment. When
the enter key is pressed the line is not executed.
1.1.10 Help
MATLAB has a host of built-in functions. For a complete list, refer to MATLAB user’s guide or refer to
the on-line Help. To obtain help on a particular topic in the list, e.g., inverse, type help inv.
help lists all primary help topics in the Command Window. Each main help topic corresponds to a
directory name on the MATLAB search path.
help functionname This command displays a description of the function and generally also includes a
list of related functions. If you cannot remember the name of the function, use the ‘lookfor’ command
and the name of some keyword associated with the function.
help toolbox/ displays the contents file for the specified directory named toolbox. It is not necessary to
give the full pathname of the directory; the last component, or the last several components, are
sufficient.
help toolbox/function displays the M-file help for function that belongs to the toolbox directory.
help syntax displays M-file help describing the syntax used in MATLAB commands and functions.
lookfor keyword This command will display a list of functions that include the keyword in their
descriptions. Other help commands that you may find useful are ‘info’, ‘what’, and ‘which’.
Descriptions of these commands can be found by using the help command.
A program can then be typed using the MATLAB word-processor software and keyboard. When typing is complete
Script files are used to process a sequence of commands that are stored in the computer memory by
typing just one word—the file’s name. The file is then executed without any display at the command
window; unless the echo command is activated, or a command ends with a comma, or a required output
is programmed.
A function file is created following the same sequence of steps outlined for the script fi les, but the first
line follows the syntax
function [output_variables] = function_name(input_variables)
where the input_variables are local, which means that their values can be used only within the function
file.
A function file can be called by typing the following at the command window:
[output_variables] = function_name(input_variables)
Function files evaluate and return the output_variables given the input_variables.
Lab Exercise 01
1) Evaluate the following mathematical expressions by transforming them into MATLAB (notation)
and estimate the values of x and y, respectively, by hand using the operational hierarchy, then use
MATLAB, and verify the results obtained by hand.
a) x=4+2 − √ ❑
3
❑
2 2
b) y=1+ 3 −4
( √❑ )
2) The following MATLAB program was written to evaluate the hypotenuse of a right triangle with
sides A = 4 and B = 3. Fill out the missing comments for a better understanding of the code.
>>A = 3; % _____________________________________________________
>>B = 4; % _____________________________________________________
>>C = sqrt(A^2+B^2); % _________________________________________
>> Hypotenuse = C; % ___________________________________________
What would be the final output displayed on the screen? (Write in the exact same format as
shown on the screen)
_____________________________________________________________________________
3) Write down the correct syntax and the associated outputs for the following:
3
c=ln (e )+ ln(e )
Syntax
Output
d=log (e )+ log ( e 3 )
Syntax
Output
e=π
Syntax
Output
f =cos ( π4 )
Syntax
Output
3 √❑
g=e
Syntax
Output
h=log ( 5 ) + ( 5 ) + log 2 5
Syntax
Output
4) Use the format long and short specifiers to compare between the outputs of the following:
a = pi
b = eps
c = a+b
d = realmax
e = realmin
f = intmax
flops
date
clock
cputime
computer
ver
beep
license
Command Function
a = pi
b = eps
c = a+b
d = realmax
e = realmin
f = intmax
flops
date
clock
cputime
computer
ver
beep
license
Problems
Construct the following programs and show the complete syntax and associated output on a separate A4
sheet.
1) A $314 coat has a discount of 30%. What is the price of the coat?
2) A student gets 9 questions right on a 20-question test.
a. Write a MATLAB program that returns the percentage of correct answers.
b. What should the student’s grade be if three questions are worth 5%, two are worth 6%, and the
remaining four are worth 7%?
3) A triangle with side lengths a, b, and c is given. The area A is given by Hero’s formula as A=√ ❑,
a+ b+c
where s= . Write a MATLAB program that returns the area for the following triangles with
2
side lengths 5, 7, and 9.
4) Three points given in terms of the Cartesian coordinates system define a triangle. Write a program to
compute the area of the triangle if the vertex points are given by the following points:
P1 (1 ,1), P 2(2, 4),∧P3 (3 , 2)
5) Write a MATLAB program that estimates your electric bill, if the appliances with the kilowatt
consumption are shown in the Table below and the cost per kilowatt-hour of usage charge by the
power provider is $0.13.
Kilowatt hours used (during a month) * cost (per kilowatt hour) = total cost in dollars ($) per
month
2 Lab 02
Object
To explore the MATLAB data objects: matrices, arrays, vectors and sets and operations applicable on
these objects
Introduction
An array is a list of numbers arranged in rows and/or columns. A one-dimensional array is a row or a
column of numbers and a two-dimensional array has a set of numbers arranged in rows and columns. An
array operation is performed element-by-element.
2.1 Row Vector
A vector is a row or column of elements.
In a row vector the elements are entered with a space or a comma between the elements inside the
square brackets. For example,
x = [7 – 1 2 – 5 8]
2.3 Matrix
The basic element in MATLAB® is the matrix. A matrix is a two-dimensional array which has numbers
in rows and columns. A matrix is entered row-wise with consecutive elements of a row separated by a
space or a comma, and the rows separated by semicolons or carriage returns. The entire matrix is
enclosed within square brackets. The elements of the matrix may be real numbers or complex numbers.
For example, to enter the matrix
A=[ 1 3 4 0−2 8 ]
The MATLAB input command is
A = [1 3 –4; 0 – 2 8]
When a command has two colons that separate three numerical arguments, following the format:
n = [initial: increment: final]
then the command returns the vector n, with elements that follow the sequence It starts with the initial
value all the way to the final value, with successive increments defined by increment, illustrated as
follows:
n = [1:0.1:2], returns the following sequence
n = [1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
The preceding sequence can also be generated without the brackets or by replacing the brackets with
parenthesis. For example,
n = 1:0.1:2 is equivalent to n = [1:0.1:2] and n = (1:0.1:2)
Note that the increment variable when negative is used to generate a decreasing sequence, illustrated as
follows:
>> n = 2:-0.1:1
n =
Columns 1 through 7
2.0000 1.9000 1.8000 1.7000 1.6000 1.5000 1.4000
Columns 8 through 11
Additionally, a multiple line command that starts in one line is continued on the next line by placing
three consecutive periods (…) called ellipsis at the end of the first line. Continuation across several lines
can be accomplished by using ellipsis repeatedly at the end of each line, but no instruction should
exceed 4096 characters.
The elements of different vectors or matrices can be concatenated to form new extended vectors or
matrices. The extended matrix is defined in terms of other vectors or matrices. For example,
let u = [0 1] and v = [2 3].
Then, evaluate:
s = [u v]
ss = [u; v]
Any element can be changed by redefining it with a new value. For example,
Defining an element outside its range can be used to expand the range or length of a matrix or vector. For example, b
s = [0 1 2 −1 0 −2]
The elements not specifically defined in a vector or matrix are assigned the default value of zero.
Observe that in s, s(5) = 0.
A set of rows or columns can be deleted by using the null vector ([ ]). For the vector s defined above, the instruction
s = [s(1) s(5)
s(6)]
An alternate way to generate a sequence n that is a row vector is by using the command:
linspace(initial, final, m_points),
where initial and final correspond to the start and end of the sequence, respectively, defined by m points,
equally spaced over the range initial/final.
For example, n = linspace(1, 2, 11) returns the sequence
n = [1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
Additionally, the syntax V(:) – refers to all the elements of the vector V (either a row or a column
vector). Whereas V(m : n) – refers to elements m through n of the vector V. For instance
>>V = [2 5 –1 11 8 4 7 –3 11]
>>u = V (2:8)
u = 5 –1 11 8 4 7 –3 11
Colons when used as an argument identify a range over a row or a column depending on its location.
For example,
if A=[ 1 4 7 2 58 3 6 9 ]
B= A ( 1 :2 ,2 :3 ) =[ 4 7 5 8 ]
2.7 Colon for a Matrix
Table 2.1 Indexing Elements from a matrix
n
dot product = A • B=∑ ai bi
i=1
dot(A, B) Computes the dot product of A and B. If A and B are matrices, the dot product is a row
vector containing the dot products for the corresponding columns of A and B.
2.11.6 Transpose
The transpose of a matrix is a new matrix in which the rows of the original matrix are the columns of the
new matrix. The transpose of a given matrix A is denoted by A T. In MATLAB, the transpose of the
matrix A is denoted by A′.
2.11.7 Determinant
A determinant is a scalar computed from the entries in a square matrix. For a 2 × 2 matrix A, the
determinant is
| A|=a 11 a22 – a21 a12
MATLAB will compute the determinant of a matrix using the det function:
Left Division
The left division is used to solve the matrix equation Ax = B where x and B are column vectors.
Multiplying both sides of this equation by the inverse of A, A–1, we have
−1 –1
A Ax=A B
−1
¿ I . x=x= A B
Hence, x= A−1 B
In MATLAB, the above equation is written by using the left division character: x = A \ B
Right Division
The right division is used to solve the matrix equation xA = B where x and B are row vectors.
Multiplying both sides of this equation by the inverse of A, A–1, we have
–1 –1
x • A A =B• A
¿ x=B • A
In MATLAB, this equation is written by using the right division character: x = B \ A
MATLAB will generate Gaussian values with a mean of zero and a variance of 1.0 if a normal
distribution is specified. The MATLAB functions for generating Gaussian values are as follows:
randn(n) Generates an n × n matrix containing Gaussian (or normal) random numbers with a mean of
0 and a variance of 1.
Randn(m, n) Generates an m × n matrix containing Gaussian (or normal) random numbers with a
mean of 0 and a variance of 1.
Lab Exercise 02
1) Do as Directed and write down the output obtained:
a) >>A= input (‘Enter the MATLAB expression’) and find sqrt(pi)
Output Comment
i.
ii.
iii.
iv.
v.
vi.
vii.
viii.
ix.
x.
xi.
Problems
1) Evaluate and give a descriptive comment next to each instruction of the following program:
a) X = [-10:1:10]
b) A = eye(length(x))
c) B = fix(rand(size(A))
d) C = zeros(size(A)) + B
e) D = tril(ceil(rand(4)))
f) E = tril(fix(5*randn(4)))
g) F = diag(d).* diag(E)
2) Create the following matrices using MATLAB:
3) Execute the following MATLAB command: x = 10 * rand(1, 20) and record vector x.
Write a set of MATLAB commands that return
a) The maximum value of x and the minimum value of x
b) The sum of all the elements of x and the product of all the elements of x
c) The average value of the elements of x and the median value of the elements of x
d) The size of x
e) Identify and display the value of the 7th element of x
f) Rearrange the values of x in ascending and descending order
4) Enter the MATLAB command x = rand(1, 100) that returns a row vector consisting of 100
random elements. Write a MATLAB program that adds all the elements of x with even indexes
indicated by the following equation:
3 Lab 03
Object
To learn printing and plotting tools and graphics in MATLAB
3.1 Introduction
Graphic capabilities are quite important in engineering, social science, natural science, education,
behavioral science, health, economy, weather, production (growth and decay), politics, biology,
accounting, and business, just to mention a few and diverse disciplines. Graphs are an important way to
communicate and visualize trends and patterns that are otherwise difficult to identify, and gain valuable
insight into a given relation or problem in this way. Information when given in the form of tables can be
easily graphed and be used to make educated predictions and decisions.
A graph, like an equation, is the language that best helps recognize the relationship, which exists
between the variables involved in a situation. The 2-D Cartesian system is the most frequently used
system by engineers and scientists. MATLAB® offers its users simple and easy-to-use graphic
commands to obtain 2-D and 3-D plots in the Cartesian coordinate system as well as in other systems.
In general, a plot can be constructed once a relation in the form of a table exists between x and y. This
relation is frequently expressed by vectors (or matrices) in MATLAB. The command plot (x, y) is
the most popular plotting command used in MATLAB, and MATLAB returns the plot of the points
defined by <xi, yi> for all is connected by straight.
3.2 Printing Formats
The command disp(‘text’) is used to display the string vector text that is enclosed in quotes, inside
parenthesis. For example, display the string: This is a string text.
MATLAB Solution
>> format compact
>> disp(pi)
3.1416
>> disp(exp(1))
2.7183
Strings texts and variables can be displayed in a text like format using the command disp([‘text’]),
as long as the argument of disp, the text is a string. A numerical variable can be converted to a character
string using the command num2str(x) or int2str(x), where x is either a number or an integer.
For example, evaluate the values of e and π, and then display each one of the integrated messages.
a. The value of e is ????, and pi = ?????
b. The value of e as an integer is ?????
MATLAB Solution
x =
2.7183
y =
2.7183
>> z = pi % number
z =
3.1416
v =
3.1416
>> w = int2str(x)
w =
>> disp ([‘The value of e as integer is ’,w,]) % note that the integer
value of 2.718 … is 3
An alternate way to display an integrated text consisting of strings and numerical values represented by
variables is by using the commands: fprintf(‘text ’,’control’, variables), or sprintf(‘text’, ‘ control’,
variables), where text is the string that will be displayed and control defines the format of the output
variables.
For example, use the commands fprintf and sprintf to display the following integrated messages:
a. The value of e is ???????, to six decimal places using an eight-character field.
b. Today is ?????, using the standard MATLAB command.
MATLAB Solution
Today is 01-Mar-2021
>> sprintf (‘The value of e is %8.6f \n’, exp (1)) % observe that
ans =
ans =
Today is 01-Mar-2021
The special sequence \n, \r, \t, \b, \f can be used to produce linefeed, carriage return,
tab, backspace, and feed character, respectively.
3.3 Plotting in MATLAB
The most common 2-D command used for plotting is the command plot(x, y). Recall that a number
is graphed on a single line. The horizontal axis is referred to as the x-axis, and the vertical axis is the y-
axis. To graph y versus x means to make a drawing that represents its solution. In order to use the
command plot(x, y), the variables x and y must be stored as two separate arrays of ordered numbers in
sequential order. The plot command can be executed if and only if the arrays x and y have the same
length (number of elements). The resulting plot may not be smooth, unless a sufficiently large number of
points are employed.
The basic command for producing a custom 2-D plot can also be written as
plot(x values, y values, ‘style option’)
where, x values and y values are vectors containing the x- and y-coordinates of points on the graph.
Style option is an optional argument that specifies the color, line-style, and the point marker style. The
style option in the plot command is a character string that consists of 1, 2, or 3 characters that specify the
color and/or the line style.
There are three ways of generating overlay plots in MATLAB, they are:
(a) Plot command
(b) Hold command
(c) Line command
(a) Plot command. Example below shows the use of plot command used with matrix argument, each
column of the second argument matrix plotted against the corresponding column of the first argument
matrix.
(b) Hold command. Invoking hold on at any point during a session freezes the current plot in the
graphics window. All the next plots generated by the plot command are added to the exiting plot. See
Example below.
(c) Line command. The line command takes a pair of vectors (or a triplet in 3–D) followed by a
parameter name / parameter value pairs as argument. For instance, the command: line (x data, y data,
parameter name, parameter value) adds lines to the existing axes.
Practice Plotting:
Plot the trigonometric function f(x) = y = 1.5 cos(2x), over the domain 0 x 2, using 5, 10, 15, and 20 points, and the
MATLAB Solution
>> y5 = 1.5*cos(2.*x5);
>> plot(x5,y5)
>> plot(x10,y10)
>> plot(x15,y15)
>> plot(x20,y20)
Use MATLAB to obtain overlay plots of the following functions: [y1 = 2.5 cos(x)] versus x and [y2 = 3.5 sin(x)] ve
MATLAB Solution
Or
A =
1 2 3 4
5 6 7 8
9 10 11 12
>> B = [1 2 3]
B =
1 2 3
>> B(4) = 4
B =
1 2 3 4
Subplots
The command subplot(m, n, p) returns m times n independent subwindows, where m and n indicate that the active fi
For example, subplot(2, 2, 3) indicates that the figure window is divided into four sub windows (two
rows by two columns) and the current plot sub window is the third (second row by first column).
For example, write a program that divides the window into four sub windows and plots in each one the
following functions:
−2 x
y 1=27 e ∧ y 2=15∗0.3 x over the range 1 x 5.
Represent the plot of y1 by discrete points indicated by the marker “*,” and y2 by a continuous (default)
solid line. Construct each plot using the following scales:
a. Linear (plot 1)
b. Linear-logarithmic (plot 2)
c. Logarithmic-linear (plot 3)
d. Logarithmic-logarithmic (plot 4)
MATLAB Solution
>> X = linspace(1,5,17);
>> y1 = 27*exp(-2*X);
>> y2 = 15*(0.3).^X;
>> % plot 1
>> subplot(2,2,1)
>> % plot 2
>> subplot(2,2,2)
>> semilogy(X,y1,’*’,X,y2)
>> % plot 3
>> subplot(2,2,3)
>> semilogx(X,y1,’*’,X,y2)
>> % plot 4
>> subplot(2,2,4)
>> loglog(X,y1,’*’,X,y2)
The command legend(‘text_1’, ‘text_2’, … ‘text_n’) is used to identify multiple plots on the same graph
by creating a box in the upper-right corner of the graph that returns the message text_1 on the first line,
identifying the line style used for the first plot; text_2 is placed on the second line and defines the line
type used for the second plot, …, and so on.
Problems
1)
let y1(x) = 10 sin(x) and y2(x) = 2 cos(x) + noise(x), where noise(x) is a random function over the range 0 x 3 u
a) [y1 = 10 sin(x)] versus x and [y2 = 2 cos(x) + noise(x)] versus. x using the same y scale
b) [y1 = 10 sin(x)] versus x and [y2 = 2 cos(x) + noise(x)] versus x using different y scales
2) Write a program that returns the following plots in a single figure:
a) [cos(x)] versus x and [sin(x)] versus x, representing the discrete points with the markers “*” and
“d,” respectively
b) [cos(x)] versus x and [sin(x)] versus x, showing the points defined by the markers in part a, and
by connecting the markers with a solid line.
Use 20 points linearly spaced over the range 0 x 2.
3) Generate an overlay plot for plotting three lines Use the plot command, the hold command and the
line command. Use the functions for plotting x-y data for plotting the following functions.
i ¿ f ( t ) =t cost , 0 ≤t ≤10 π
t 3t
ii ¿ x=e , y=100+ e ,0 ≤ t ≤ 2 π
4) Using appropriate example, make the following 2D plots
5) Create a program that returns the plots of y1(x) versus x and y2(x) versus x with the specs indicated
as follows:
a) Use the marker “*” to indicate the points of y1(x) and connect the points with a solid line
b) Use the marker “+” to indicate the points of y2(x) and connect the points with a solid line
c) Label properly the x and y axes
d) Place the following text as title: 5 cos(2X) and 3 sin(X) versus X
e) Place the text 5 cos 2x at the (Cartesian coordinate) location <0.5, 4>
f) Place the text 3 sin(X) using the command gtext at the (Cartesian coordinate) location <2, 3>
g) Add an appropriate legend onto your figure.
4 Lab 04
Object
To learn methods the flow of programming in MATLAB through loops.
4.1 Introduction
One most significant feature of MATLAB is its extendibility through user-written pro- grams such as
the M-files. M-files are ordinary ASCII text files written in MATLAB language. A function file is a
subprogram.
4.2 Relational and Logical Operators
A relational operator compares two numbers by finding whether a comparison statement is true or false.
A logical operator examines true/false statements and produces a result which is true or false according
to the specific operator. Relational and logical operators are used in mathematical expressions and also
in combination with other commands, to make decision that control the flow a computer program.
Table 3.1 MATLAB has six relational operators as shown below.
Examples showing relational commands for the case where the arguments, A and B are vectors, are
illustrated in Table below, for A=[0 12 3]∧B=[−1 2 13]
4.3 Order of Precedence
1 (highest) Parentheses (If nested parentheses exist, inner
have precedence).
2 Exponentiation.
4 Multiplication, Division.
5 Addition, Subtraction.
The syntax and format of the simplest form of the if-end statement is as follows:
if <condition>
<statements>
end
Only one decision-making <condition> is used, and if this <condition> is true, then the <statements> are
executed, followed by the end. However, if the <condition> is false, then the <statements> are not
executed, followed by the end.
The if-end statement can be expanded to include two different paths by executing two different sets of
statements based on a single decision-making condition.
The syntax and format are as follows:
if <condition>
<statements _ 1>
else
<statements _ 2>
end
Meaning that if <condition> is true, then <statements_1> is executed followed by the end (exit); but if
<condition> is not true, then <statements_2> is executed followed by the end (exit). When several levels
of if-else statements are nested, it may be difficult to find which logical expressions must be true (or
false) to execute each set of statements. In such cases, the elseif clause is used to clarify the program
logic.
The syntax and format are as follows:
if <condition _ 1>
<statements _ 1>
else
<statements _ n>
end
Meaning that if <condition_1> is true, then the <statements_1> are executed followed by the end (exit); but if <cond
<statements>
end
referred as the for-end statement is used to create a loop that executes repetitively the <statements> a fix
number of times based on the spec <range>. The spec <range> is frequently given by a vector or a
matrix. In either case, the commands between the for and end indicated by <statements> are executed
once for each column of the <range>.
If multiple loops are required, the loop structure must be nested, meaning that each loop must be
constructed inside another loop.
The commands break, error, and return are useful when operating inside a loop to stop or
control its execution. The break command unconditionally terminates the execution of a loop and the
program continues with the first instruction after the end command. The command error (‘text’) stops
the execution of a loop, displays the string text on the computer screen, and transfers control to the
keyboard. The command return produces an unconditional exit from a loop, ignoring the instructions
inside the loop.
A few words of advice—a good programmer must be able to understand the mechanisms and conditions
set, and trace the logic used in repeating a block of commands by using loops and nested loops when
analyzing a program. Looping and decision making constitutes, the main power and capability of most
digital computer systems. The analysis of a looping sequence must be followed either mentally by the
experienced programmer or by relying on a flowchart or table by the beginner or less experienced
programmer. A recommended practice is to assign values to the loop variables tracing its execution for
at least two complete cycles to get a good insight of the mechanism used and be able to visualize a
pattern of the purpose and nature of the looping algorithm.
4.4.3 The While-End
The command
while <condition>
<statements>
end,
referred as the while-end statements is used to create a loop in which the <statements> are executed
repetitively for an indefinite number of times as long as the specified <condition> is and remains true.
When the <condition> is no longer true, then the program exits the loop and continues with the normal
execution of the remaining of the program by executing the first instruction after the end statement.
Lab Exercise 04
1) Write a program that returns
a) The matrix B with the information that indicates if each element of A is greater than 2
b) The matrix C with the information that indicates if each element of A is negative
c) The matrix D with the information that indicates if each element of A is equal to 2
4) In the given syntax below, write down the probable output or comment corresponding to each line.
Syntax Output
>> A = [0 1 2; 4 5 6; -1 -2 -3]
>> X = -3:10
>> Y= []
disp(‘*****************************************’)
disp(‘******************************************’)
format compact
n =1;
for K= A
ColumnSum = K(1)+K(2)+K(3)
ColumnProd = K(1)*K(2)*K(3)
n = n+1;
end
6) write a program that returns a 13 by 3 matrix A where the first column of A consists of the
sequence 1, 2, 3, 4, …, 13; the second column of A consists of the sequence 2, 4, 6, 8, …, 24, 26;
and the third column of A consists of the sequence 3, 6, 9, 12, …, 36, 39.
end
end
9) Create a program that evaluates the sum_x defined by the following equation (for the first 10
digits) using a for and a while loop.
5 Lab 05
Object
To learn to use MATLAB to (1) generate polynomials, (2) manipulate polynomials, (3) perform partial-
fraction expansions. (4) find Laplace transforms for time functions and, (5) find time functions from
Inverse Laplace transforms
5.1 Control Systems Fundamentals
A basic control system has an input, a process, and an output. The basic objective of a control system is
of regulating the value of some physical variable or causing that variable to change in a prescribed
manner in time. Control systems are typically classified as open loop or closed-loop. Open-loop control
systems do not monitor or correct the output for disturbances whereas closed-loop control systems do
monitor the output and compare it with the input. In a closed-loop control system if an error is detected,
the system corrects the output and thereby corrects the effects of disturbances. In closed-loop control
systems, the system uses feedback, which is the process of measuring a control variable and returning
the output to influence the value of the variable.
Block diagrams display the operational units of a control system. Each block in a component block
diagram represents some major component of the control system, such as measurement, compensation,
error detection, and the plant itself. It also depicts the major directions of information and energy flow
from one component to another in a control system. A block can represent the component or process to
be controlled. Each block of a control system has a transfer function (represented by differential
equations) and defines the block output as a function of the input.
Control systems engineering consists of analysis and design of control systems configurations. Control
systems are dynamic, in that they respond to an input by first undergoing a transient response before
attaining a steady-state response which corresponds to the input.
There are three main objectives of control systems analysis and design. They are:
1. Producing the response to a transient disturbance which is acceptable
2. Minimizing the steady-state errors: Here, the concern is about the accuracy of the steady-state
response
3. Achieving stability: Control systems must be designed to be stable. Their natural response should
decay to a zero value as time approaches infinity, or oscillate.
System analysis means the investigation, under specified condition, of the performance of a system
whose mathematical model is known. Analysis is investigation of the properties and performance of an
existing control system.
By synthesis we mean using an explicit procedure to find a system that will perform in a specified way.
System design refers to the process of finding a system that accomplishes a given task. Design is the
selection and arrangement of the control system components to perform a prescribed task. The design of
control systems is accomplished in two ways: design by analysis in which the characteristics of an
existing or standard system configuration are modified, and design by synthesis, in which the form of
the control system is obtained directly from its specifications.
Control system design and analysis objectives include: producing the response to a transient disturbance
follows a specified pattern (over-damped or under damped), minimizing the steady-state errors, and
achieving the stability.
5.2 Polynomials in MATLAB
A polynomial is a function of a single variable that can be expressed in the following form:
f (x)=a0 x n+ a1 x n – 1 +a2 x n – 2 +…+ an – 1 x 1 +a n
where the variable is x and the coefficients of the polynomial are represented by the values a0, a1, …
and so on. The degree of a polynomial is equal to the largest value used as an exponent.
A vector represents a polynomial in MATLAB. When entering the data in MATLAB, simply enter each
coefficient of the polynomial into the vector in descending order. For example, consider the polynomial
5 4 2
5 s +7 s +2 s – 6 s+10
To enter this into MATLAB , we enter this as a vector as
>> x = [5 7 0 2 – 6 10]
x =
5 7 0 2 – 6 10
It is necessary to enter the coefficients of all the terms. MATLAB contains functions that perform
polynomial multiplication and division, which are listed below:
conv(a, b) Computes a coefficient vector that contains the coefficients of the product of polynomials
represented by the coefficients in a and b. The vectors a and b do not have to be the same size.
[q, r] = deconv(n, d) Returns two vectors. The first vector contains the coefficients of the
quotient and the second vector contains the coefficients of the remainder polynomial.
The MATLAB function for determining the roots of a polynomial is the roots function:
root(a) Determines the roots of the polynomial represented by the coefficient vector a. The roots
function returns a column vector containing the roots of the polynomial; the number of roots is equal to
the degree of the polynomial.
poly(r) Determines the coefficients of the polynomial whose roots are contained in the vector r. The
output of the function is a row vector containing the polynomial coefficients. The value of a polynomial
can be computed using the polyval function, polyval (a, x). It evaluates a polynomial with
coefficients a for the values in x. The result is a matrix the same size ad x. For instance, to find the value
of the above polynomial at s = 2,
>> x = polyval([5 7 0 2 – 6 10], 2)
x =
278
To find the roots of the above polynomial, we enter the command roots (a) which determines the roots
of the polynomial represented by the coefficient vector a.
>>roots([5 7 0 2 – 6 10])
ans =
– 1.8652
– 0.4641 + 1.0832i
– 0.4641 – 1.0832i
0.6967 + 0.5355i
0.6967 – 0.5355i
% or
>> x = [5 7 0 2 – 6 10]
x =
5 7 0 2 – 6 10
>> r = roots(x)
r =
– 1.8652
– 0.4641 + 1.0832i
– 0.4641 – 1.0832i
0.6967 + 0.5355i
0.6967 – 0.5355i
>>poly(r)
the command poly always returns a value of unity to the leading coefficient. To multiply two
polynomials together, we enter the command conv.
>>x = [2 5];
>>y = [1 3 7];
>>z = conv(x, y)
z =
2 11 29 35
To divide two polynomials, we use the command deconv. The MATLAB command [D, R] =
P1 R
deconv (P1, P2) performs the following polynomial operation, =D+ , and returns D and R
P2 P2
as row vectors, where D is the quotient polynomial and R is the residue or remainder polynomial.
z = [2 11 29 35]; x = [2 5]
g = 1 3 7
t = 0 0 0 0
Hence,
num = [b(1) b(2) … b(n)]
The MATLAB command [num, den] = residue (r, p, k), where r, p and, k are the output
from MATLAB converts the partial fraction expansion back to the polynomial ratio B(s)/A(s).
Example:
Resolve the given fraction into its constituent partial fractions.
[K,p,k]= residue (numf,denf) %The residue function takes the num and den as
input arguments
MATLAB OUTPUT:
The K vector gives the values of the residues, the p vector returns the polynomial values (poles which
we will study later!) and the k vector returns any constant or extra terms in the partial fraction
expansion. (In this case there are none). Hence, the final output can be considered as:
2 -2 -2 2
(s+1)(s+2)^2 (s + 1) (s + 2) (s + 2)^2
symvar(s) Returns the independent variable for the symbolic expression s. symvar(S) searches the
string S for identifiers other than 'i', 'j’, ‘pi', 'inf', 'nan', 'eps' and common functions. The variables are
returned as a cell array of strings. If no such variable exists, the empty cell array {} is returned.
For example:
Expression s symvar(s)
>>syms t >>syms t x
ans = ans =
(s+1)(s+2)^2 (s + 1) (s + 2) (s + 2)^2
The command ilaplace will find the inverse Laplace transform of a Laplace function.
syms s %The syms function makes s a symbol that is treated like a variable
Output:
f =
Use the pretty command to give your output a standard look similar to textbook mathematical
expressions.
pretty(f) %makes the output easier to read
Output:
b)
4) Expand the following function F(s) into partial fractions using MATLAB. Determine the inverse
Laplace transform of F(s).
5) Find the Laplace transform of the following function using MATLAB.
a) f (t )=7 t 3 cos(5 t +60 °)
b) f (t)=5 e – 2 t cos 5 t
b) Generate symbolically F(s) shown. Obtain your result symbolically in both factored and
polynomial forms.
c) Find the Laplace transform of f(t) shown in part a.
d) Find the inverse Laplace transform of F(s) shown in part b
6 Lab 06
Object
To learn to use MATLAB to (1) generate transfer functions, (2) manipulate transfer functions, (3)
identifying poles and zeros of transfer functions (4) plotting poles and zeros of transfer functions (5) To
study model conversion techniques
6.1 Transfer Functions
The transfer function of a linear time invariant system is expressed as a ratio of two polynomials. The
transfer function for a single input and a single output (SISO) system is written as:
You can use the tf command to generate a transfer function directly as well. Like the residue command
it takes the coefficients of numerator and the denominator as input vectors.
F=tf([3],[1 2 5 0])
Output:
A useful trick is to create the Laplace variable, s. That way, you can specify polynomials using s as the
polynomial variable and easily represent the same transfer function.
>>s=tf('s');
>>sys= s/(s^2 + 2*s + 1)
The command printsys (num, den, ‘s’) prints the numerator and the denominator in terms of
the ratio of polynomials in terms of the transform variable s. It is described the example below.
Consider the transfer functions
2
6 s +1
G ( s )= 3 2
∧ H ( s )=¿ ¿
s +3 s + 3 s+ 1
numg = [6 0 1]; deng = [1 3 3 1];
printsys(numg, deng)
Write a code to evaluate G(s)/H(s) and then print the entire system
The MATLAB command [z, p, k] = tf2zp(num,den) is used to find the zeros, poles, and gain K
of B(s)/A(s).If the zeros, poles, and gain K are given, the following MATLAB command can be used to
find the original num/den: [num,den] = zp2tf (z, p, k)
The pole zero’s locations can also me displayed as a map on the complex plane using the pzmap
command. pzmap(num,den)
5 4 3 2
6 s +18 s +25 s +75 s +4 s +12
G ( s )= 5 4 3 2
s +6 s +14 s + 16 s + 9 s +2
The pole-zero map clearly shows the five zero locations and two pole locations. This cannot be the case
since we know that the number of poles must be greater than or equal to the number of zeros. Using the
roots function, we can be certain that there are in fact four poles at s = -1. Hence, multiple poles or
multiple zeros at the same location cannot be discerned on the pole-zero map.
6.3 Model Conversion
There are a number of functions in MATLAB that can be used to convert from one model to another.
These conversion functions and their applications are summarized in Table below:
When applying this equation, it is best to construct a free-body diagram (FBD) of the system showing all
of the applied forces.
Example: Mass-Spring-Damper System
The free-body diagram for this system is shown below. The spring force is proportional to the
displacement of the mass, , and the viscous damping force is proportional to the velocity of the
mass, . Both forces oppose the motion of the mass and are, therefore, shown in the negative -
direction. Note also that corresponds to the position of the mass when the spring is unstretched.
Now we proceed by summing the forces and applying Newton’s second law, Equation (11), in each
direction. In this case, there are no forces acting in the -direction; however, in the -direction we have:
This equation, known as the governing equation, completely characterizes the dynamic state of the
system. Later, we will see how to use this to calculate the response of the system to any external
input, , as well as to analyze system properties such as stability and performance.
To determine the state-space representation of the mass-spring-damper system, we must reduce the
second-order governing equation to a set of two first-order differential equations. To this end, we choose
the position and velocity as our state variables.
The position variable captures the potential energy stored in the spring, while the velocity variable
captures the kinetic energy stored by the mass. The damper only dissipates energy, it doesn't store
energy. Often when choosing state variables it is helpful to consider what variables capture the energy
stored in the system.
The state equation in this case is:
If, for instance, we are interested in controlling the position of the mass, then the output equation is:
A = [0 1; -k/m -b/m];
B = [0 1/m]';
C = [1 0];
D = [0];
sys = ss(A,B,C,D)
sys =
A =
x1 x2
x1 0 1
x2 -1 -0.2
B =
u1
x1 0
x2 1
C =
x1 x2
y1 1 0
D =
u1
y1 0
and, therefore, the transfer function from force input to displacement output is
Lab Exercise 06
1) Use MATLAB to find the zeros and poles of the given transfer function
Mathematical functions such as summers and gains are in the Math library.
Constants, common input functions, and clock can all be found in the Sources library.
Scope, To Workspace blocks can be found in the Sinks library.
Simulink is a graphical interface that allows the user to create programs that are actually run in
MATLAB. When these programs run, they create arrays of the variables defined in Simulink that can be
made available to MATLAB for analysis and/or plotting. The variables to be used in MATLAB must be
identified by Simulink using a “To Workspace” block, which is found in the Sinks library. (When using
this block, open its dialog box and specify that the save format should be Matrix, rather than the default,
which is called Structure.) The Sinks library also contains a Scope, which allows variables to be
displayed as the simulated system responds to an input. This is most useful when studying responses to
repetitive inputs. Simulink uses blocks to write a program. Blocks are arranged in various libraries
according to their functions. Properties of the blocks and the values can be changed in the associated
dialog boxes. Some of the blocks are given below.
7.2.1 SUM (Math library)
A dialog box obtained by double-clicking on the SUM block performs the configuration of the SUM
block, allowing any number of inputs and the sign of each. The sum block can be represented in two
ways in Simulink, by a circle or by a rectangle. Both choices are shown X1
● Start MATLAB.
● Start Simulink.
● Open the libraries that contain the blocks you will need. These usually will include the Sources,
Sinks, Math and Continuous libraries, and possibly others.
● Open a new Simulink window.
● Drag the needed blocks from their library folders to that window. The Math library, for example,
contains the Gain and Sum blocks.
● Arrange these blocks in an orderly way corresponding to the equations to be solved.
● Interconnect the blocks by dragging the cursor from the output of one block to the input of another
block. Interconnecting branches can be made by right-clicking on an existing branch.
● Double-click on any block having parameters that must be established, and set these parameters. For
example, the gain of all Gain blocks must be set. The number and signs of the inputs to a Sum block
must be established. The parameters of any source blocks should also be set in this way.
● It is necessary to specify a stop time for the solution. This is done by clicking on the Simulation >
Parameter’s entry on the Simulink toolbar.
At the Simulation > Parameter’s entry, several parameters can be selected in this dialog box, but the
default values of all of them should be adequate for almost all of the exercises. If the response before
time zero is needed, it can be obtained by setting the Start time to a negative value. It may be necessary
in some problems to reduce the maximum integration step size used by the numerical algorithm. If the
plots of the results of a simulation appear “choppy” or composed of straight-line segments when they
should be smooth, reducing the max step size permitted can solve this problem.
7.4 Mass-Spring System Model
Consider the Mass-Spring system used in the previous exercise as shown in the figure, where F s (x) is
the spring force, F f (ν ) is the friction coefficient, x (t) is the displacement and F a (t) is the applied force
The differential equation for the above Mass-Spring system can then be written as follows
Exercise 1: Modeling of a second order system Construct a Simulink diagram to calculate the
response of the Mass-Spring system. The input force increases from 0 to 8 N at t = 1 s. The
parameter values are M = 2 kg, K= 16 N/m, and B =4 N.s/m. Steps:
Draw the free body diagram.
Write the modeling equation from the free body diagram
Solve the equations for the highest derivative of the output.
Draw a block diagram to represent this equation.
Draw the corresponding Simulink diagram.
Use Step block to provide the input fa(t).
In the Step block, set the initial and final values and the time at which the step occurs.
Use the “To Workspace” blocks for t, fa(t), x, and v in order to allow MATLAB to plot the desired responses. Set th
Select the duration of the simulation to be 10 seconds from the Simulation > Parameters entry on the toolbar.
Given below is a file that will set up the MATLAB workspace by establishing the values of
the parameters needed for the Simulink simulation of the given model. M-file for parameter values
● Enter the command exl_parameter in the command window. This will load the
parameter values of the model.
● Open the Simulink model exl_model.mdl and start the simulation by clicking on the toolbar entry
Simulation> Start.
● Enter the command exl_plot in the command window to make the plot.
8 Lab 08
Object:
Learning simulation of linear systems with Unit Step and Impulse Inputs.
Theory:
Model is a mathematical representation of a system
– Models allow simulating the system
– Models can be used for conceptual analysis
– Models are never exact.
– Linear models
o Have simple structure.
o Can be analyzed using powerful mathematical tools.
o Can be matched against real data using known procedures.
o Many simple physics models are linear.
o They are just models, not the real systems.
You can simulate the LTI systems to inputs like impulse, step and other standard inputs and see the plot
of the response in the figure window. MATLAB command ‘impulse’ calculates the unit impulse
response of the system, ‘step’ calculates the unit step response of the system and ‘lsim’ simulates the
(time) response of continuous or discrete linear systems to arbitrary inputs. When invoked without left-
hand arguments, all three commands plots the response on the screen. For example:
The lsim command is quite similar to the step command (actually, the step command is just a special
case of lsim). Given a system described as an LTI object, the lsim command can run a simulation of the
system using arbitrary inputs and initial conditions.
The command lsim(sys,U,T,X0) plots the time response of a linear time-invariant system. This
system can be continuous or discrete. For a continuous-time system, the differential equation is
integrated from time T(0) to T(length(T)), starting at the initial condition X0 and using the input U. The
input vector must have the same number of entries as the time vector. If the initial conditions are all
zero, X0 may be omitted.
For a discrete-time system, U should be sampled at the same rate as the system (T is then redundant and
may be omitted or set to the empty matrix, i.e. [ ]).
1 0 0
0 1 0];
B = [1
0];
C = [0 0 1];
D = 0;
As you can see from the dimensions of the matrices, this system has three states, one input, and one
output. Let's say we want to plot the response of the system with a non-zero initial condition and no
input. This can be done in the following manner.
no plot is drawn on the screen. MATLAB returns the output and state time history in the
matrices Y and X respectively. In general, Tsim is the same as T. However, in some cases, T is
resampled when intersample oscillations occur. Then, Tsim is the time actually used in simulation. The
matrix Y has as many columns as there are outputs and has length(Tsim) rows. X has as many columns
as there are states and has length(Tsim) rows. The plot command can then be used to plot the response.
Note that X can be omitted.
Now let's plot the step response for the system given above; the input U is 1 for all positive time, and let
the initial conditions be zero.
The plot above shows the step response of the system. We can also plot the response of the system to
any other input that we choose. For example, we can simulate the system's response to a sinusoidal
input, say u(t) = 0.1 sin(5 t + 1), employing the code given below.
T = 0:0.01:10;
U = 0.1*sin(5*T+1);
num=1;
den=[1 20 40 60];
sys_tf = tf(num,den);
lsim(sys_tf,U,T);
Because any transfer function can be represented using many different sets of state-space matrices, you
can only simulate a system in transfer function form with zero initial conditions (and cannot obtain the
state trajectories); see the conversions page for more details.
The response of linear systems to arbitrary inputs can also be generated from within the Linear System
Analyzer.
Practice:
To obtain an impulse response
>> H = tf([2 5 1],[1 2 3]);
>>impulse(H)
Time-interval specification:
To contain the response of the system you can also specify the time interval to simulate the system to.
For example,
>> t = 0:0.01:10;
>> impulse(H,t)
Or
>> step(H,t)
Simulation to Arbitrary Inputs:
To simulates the (time) response of continuous or discrete linear systems to arbitrary inputs use ‘lsim’.
When invoked without left-hand arguments, ‘lsim’ plots the response on the screen. lsim(sys,u,t)
produces a plot of the time response of the LTI model sys to the input time history ‘t’,’u’. The vector ‘t’
specifies the time samples for the simulation and consists of regularly spaced time samples.
T = 0:dt:Tfinal
The matrix u must have as many rows as time samples (length(t)) and as many columns as system
inputs.
⮚ MATLAB
⮚ Simulink
Category
Soft-Experiment
Deliverables
A complete lab report including the following:
⮚ Design two systems in Simulink, one for impulse response and one for step response. Then use the
derived transfer function to obtain the result using scope. To find both the responses in MATLAB,
write the required code and finally compare both the results (of Simulink and MATLAB).
⮚ MATLAB scripts and their results for all the assignments and exercises should be properly reported.
10 Lab 10
Object
To learn commands in MATLAB that would be used to reduce linear systems block diagram using
series, parallel and feedback configuration.
Series configuration: If the two blocks are connected as shown below then the blocks are said to
be in series. It would like multiplying two transfer functions. The MATLAB command for the
such configuration is “series”.
Example 1: Given the transfer functions of individual blocks generate the system transfer
function of the block combinations.
Parallel configuration: If the two blocks are connected as shown below then the blocks are said to be in
parallel. It would like adding two transfer functions.
The MATLAB command for implementing a parallel configuration is “parallel” as shown
below:
Example 2: For the previous systems defined, modify the MATLAB commands to obtain the
overall transfer function when the two blocks are in parallel.
Feedback configuration: If the blocks are connected as shown below then the blocks are said to
be in feedback. Notice that in the feedback there is no transfer function H(s) defined. When not
specified, H(s) is unity. Such a system is said to be a unity feedback system.
The MATLAB command for implementing a feedback system is “feedback” as shown below:
When H(s) is non-unity or specified, such a system is said to be a non-unity feedback system as
shown below:
A non-unity feedback system is implemented in MATLAB using the same “feedback”
command as shown:
Example 3: Given a unity feedback system as shown in the figure, obtain the overall transfer
function using MATLAB:
Example 4: Given a non-unity feedback system as shown in the figure, obtain the overall
transfer function using MATLAB:
The result is as shown below:
Exercise 1: For the following multi-loop feedback system, get closed loop transfer function and the
corresponding pole-zero map of the system.
Lab Exercise 10
11 Lab 11
Object
to study the performance characteristics of first order systems using MATLAB
Overview First Order Systems:
An electrical RC-circuit is the simplest example of a first order system. It comprises of a resistor and
capacitor connected in series to a voltage supply as shown below on Figure 1.
If the capacitor is initially uncharged at zero voltage when the circuit is switched on, it starts to charge
due to the current ‘i' through the resistor until the voltage across it reaches the supply voltage. As soon
as this happens, the current stops flowing or decays to zero, and the circuit becomes like an open circuit.
However, if the supply voltage is removed, and the circuit is closed, the capacitor will discharge the
energy it stored again through the resistor. The time it takes the capacitor to charge depends on the time
constant of the system, which is defined as the time taken by the voltage across the capacitor to rise to
approximately 63% of the supply voltage. For a given RC-circuit, this time constant is r = RC. Hence its
magnitude depends on the values of the circuit components.
The RC circuit will always behave in this way, no matter what the values of the components. That is, the
voltage across the capacitor will never increase indefinitely. In this respect we will say that the system is
passive and because of this property it is stable.
For the RC-circuit as shown in Fig. 1, the equation governing its behavior is given by
where vc(t) is the voltage across the capacitor, R is the resistance and C is the capacitance. The constant
τ = RC is the time constant of the system and is defined as the time required by the system output i.e.
v c (t) to rise to 63% of its final value (which is E). Hence the above equation can be expressed in terms
of the time constant as:
Obtaining the transfer function of the above differential equation, we get
where τ is time constant of the system and the system is known as the first order system. The
performance measures of a first order system are its time constant and its steady state.
Exercise
a) Given the values of R and C, obtain the unit step response of the first order system.
a. R=2KΩ and C=0.01F
b. R=2.5KΩ and C=0.003F
b) Verify in each case that the calculated time constant (r = RC) and the one measured from the
figure as 63% of the final value are same. Obtain the steady state value of the system
12 Lab 12
Object
The differential equation for the above Mass-Spring system can be derived as follows.
provided that, all the initial conditions are zeros. Then the transfer function representation of the system
is given by
where 0 < ζ < 1. The transient response of the system changes for different values of damping ratio, ζ.
Standard performance measures for a second order feedback system are defined in terms of step
response of a system. Where, the response of the second order system is shown below.
where MPt is the peak value of the time response, and fv is the final value of the response.
Settling Time: The time required for the system’s output to settle within a certain percentage of the
input amplitude (which is usually taken as 2%). Then, settling time, Ts, is calculated as