Professional Documents
Culture Documents
Csfile Final Shubham
Csfile Final Shubham
Csfile Final Shubham
Sr.no
. Experiment names Signature
1 Introduction to Matlab
What is MATLAB?
MATLAB is widely used in all areas of applied mathematics, in education and
research at universities, and in the industry. MATLAB stands for MATRIX
LABORATORY and the software is built around vectors and matrices. This makes
the software particularly useful for linear algebra but MATLAB is also a great tool
for solving algebraic and differential equations and for numerical integration.
MATLAB has powerful graphic tools and can produce nice pictures in both 2D
and 3D. It is also a programming language and is one of the easiest
programming languages for writing mathematical programs. MATLAB also has
some toolboxes useful for signal processing, image processing, optimization, etc.
Octave has extensive tools for solving common numerical linear algebra
problems, finding the roots of nonlinear equations, integrating ordinary functions,
manipulating polynomials, and integrating ordinary differential and differential
algebraic equations. It is easily extensible and customizable via user-defined
functions written in Octave’s own language, or using dynamically loaded modules
written in C++, C, Fortran, or other languages.
GNU Octave is also freely redistributable software. You may redistribute it and/or
modify it under the terms of the GNU General Public License (GPL) as published
by the Free Software Foundation.
Octave was written by John W. Eaton and many others. Because Octave is free
software you are encouraged to help make Octave more useful by writing and
contributing additional functions for it, and by reporting any problems you may
have.
Figure - Editor Window
AIM: - To obtain Pole, zero, gain values from a given transfer function
THEORY -
The pole-zero gain of a transfer function is the product of its poles, zeros, and gain constant.
H(s) = (s + 1) / (s^2 + 2s + 5)
To find the pole-zero gain of H(s), we first need to factorize it in terms of its poles, zeros,
and gain constant. In this case, we have one zero at s = -1 and two poles at s = -1 + 2i
and s = -1 - 2i. The gain constant is K = 1.
Therefore, the pole-zero gain of H(s) is:
= 1 / (-5) = -0.2
Therefore, the pole-zero gain of H(s) at s = 0 is -0.2. This value gives an indication of the
overall gain or attenuation of the system at low frequencies.
CODE-
pkg load control
den=[2 6 4];
THEORY -
A pole-zero map is a graphical representation of the location of poles and zeros of a
transfer function in the complex plane. Poles and zeros are the values of s that make
the transfer function H(s) infinite or zero, respectively.
To construct the pole-zero map of a transfer function, we first factorize the transfer function in
terms of its poles and zeros. For example, consider the transfer function: H(s) = (s + 1) / (s^2
+ 2s + 5)
The poles of this transfer function are the roots of the denominator polynomial s^2 + 2s +
5. We can find these roots by using the quadratic formula:
s = (-2 ± sqrt(2^2 - 4*1*5)) / (2*1) = -1 ± 2i So, the poles
H(s) are located at s = -1 + 2i and s = -1 - 2i.
The zeros of the transfer function are the roots of the numerator polynomial s + 1. We can find
this root by setting the numerator equal to zero:
s + 1 = 0 So, the zero of H(s) is
located at s = -1.
Now, we can plot the poles and zeros on the complex plane. The poles are marked with an "x"
and the zeros are marked with an "o". In this example, the pole-zero map of H(s) is:
x
|
o |
x
The pole-zero map provides important information about the behavior of the system. For
example, the distance of the poles from the imaginary axis determines the damping of
the system, while the frequency of oscillation is determined by the imaginary part of the
poles. The location of the zeros can affect the stability of the system and the frequency
response.
CODE -
pkg load control;
num =[1 2 3];
den =[4 5 6 7];
h =tf(num,den);
pzmap(h);
tf(h) ;
OUTPUT -
THEORY -
The step and impulse response of a first-order system can also be analyzed using its transfer
function: H(s) = K / (s + τ) where K is the system gain, τ is the time constant, and s is the Laplace
variable.
The step response of the system is the output of the system when the input is a step function, u(t) =
U0 for t >= 0. The Laplace transform of a step function is U0/s, so the output can be found by taking
the inverse Laplace transform of the product of the transfer function and the input:
This equation describes the response of the system to a step input. The step response rises
exponentially from zero to the steady-state value of U0 with a time constant τ.
The impulse response of the system is the output of the system when the input is an impulse function,
δ(t). The Laplace transform of an impulse function is 1, so the output can be found by taking the
inverse Laplace transform of the product of the transfer function and 1:
This equation describes the response of the system to an impulse input. The impulse response is a
decaying exponential with time constant τ. The impulse response is useful for analyzing the frequency
response of the system and identifying resonant frequencies.
In summary, for a first-order system, the step response rises exponentially to the steady-state value
with a time constant τ, while the impulse response is a decaying exponential with the same time
constant.
CODE -
pkg load control
clc
clear
R=3 u=2
s=tf('s')
G=1/(s+R)
step(u*G)
figure(1) impulse
(u*G) figure(2)
step(u*G/s)
OUTPUT-
THEORY -
The step and impulse response of a second-order system can be analyzed using its transfer function:
H(s) = K / (s^2 + 2ζωn s + ωn^2) where K is the system gain, ζ is the damping ratio, ωn is the natural
variable.
The step response of the system is the output of the system when the input is a step function, u(t) =
U0 for t >= 0. The Laplace transform of a step function is U0/s, so the output can be found by taking
the inverse Laplace transform of the product of the transfer function and the input:
natural frequency.
This equation describes the response of the system to a step input. The step response is initially zero,
then rises to the steady-state value of U0 with a settling time that depends on the damping ratio and
natural frequency. For a critically damped system (ζ = 1), the response reaches the steady-state value
without any overshoot, while an underdamped system (ζ < 1) exhibits overshoot before reaching the
steady-state value, and an overdamped system (ζ > 1) has a slower response with no overshoot.
The impulse response of the system is the output of the system when the input is an impulse function,
δ(t). The Laplace transform of an impulse function is 1, so the output can be found by taking the
inverse Laplace transform of the product of the transfer function and 1:
y(s) = H(s) = K / (s^2 + 2ζωn s + ωn^2)
u(t)
This equation describes the response of the system to an impulse input. The impulse response is a
decaying sine wave with frequency ωd and damping factor ζωn. The impulse response is useful for
analyzing the frequency response of the system and identifying resonant frequencies.
CODE -
pkg load control
clc;
clear;
r=3;
u=2;
s=tf('s');
g=1/(s*s+2*s+r);
figure(1);
step(u*g);
figure(2);
impulse(u*g);
OUTPUT -
Figure - Impulse response
AIM- DETERMINATION OF STEP & IMPULSE RESPONSE FOR A TYPE ‘0’, TYPE
‘1’, TYPE ‘2’ SYSTEM
In control system theory, a system is classified as Type 0, Type 1, or Type 2 based on the number of
integrators (or poles at the origin) in its transfer function.
A Type 0 system has no integrators in its transfer function, meaning that the output of the system is
proportional to the input. Examples of Type 0 systems include a simple gain block or an amplifier with
no feedback.
A Type 1 system has one integrator in its transfer function, meaning that the output of the system is
proportional to the integral of the input. Examples of Type 1 systems include a simple first-order
lowpass filter or an integrator with unity feedback.
A Type 2 system has two integrators in its transfer function, meaning that the output of the system is
proportional to the double integral of the input. Examples of Type 2 systems include a simple
secondorder low-pass filter or a cascaded integrator-comb filter.
The type of a system is important in control theory because it determines the system's steady-state
response to a step input. A Type 0 system will have a non-zero steady-state output for a non-zero
step input, while a Type 1 system will have zero steady-state error for a step input, but non-zero
steadystate error for a ramp input. A Type 2 system will have zero steady-state error for both step and
ramp inputs.
Knowing the type of a system is also important in designing controllers, as it affects the controller's
performance and stability. For example, a Type 0 system may require a proportional (P) controller,
while a Type 1 system may require a proportional-integral (PI) controller, and a Type 2 system may
require a proportional-integral-derivative (PID) controller for optimal performance.
CODE - TYPE 0
Output -
OUTPUT -
THEORY -
Root locus is a graphical method used to analyze the stability of a system in control theory. It is a plot
of the locations of the closed-loop system poles as a parameter, such as the gain or a controller
parameter, is varied.
The root locus is typically drawn on the complex plane, with the real and imaginary parts of the
closedloop system poles plotted as a function of the parameter being varied. By analyzing the root
locus, one can determine the stability of the system and design a controller that satisfies specific
requirements, such as gain margin and phase margin.
The root locus method is based on the concept that the stability of a system depends on the location
of the closed-loop poles. Specifically, if all the poles of the closed-loop system lie on the left-hand side
of the complex plane, the system is stable, and if any of the poles lie on the right-hand side of the
complex plane, the system is unstable.
The root locus is used to find the values of the parameter for which the poles of the closed-loop
system lie on the imaginary axis. These are called the breakaway and re-entry points, and they
represent the limits of the region of stability for the system. The root locus can also be used to find the
gain and phase margins of the system.
Overall, the root locus is a powerful tool for designing controllers and analyzing the stability of
systems in control theory.
CODE -
pkg load control
clc;
clear;
num = [1 1]
den = conv([1 0],[.5 1])
g = tf(num,den); rlocus(g)
OUTPUT -
Root locus of transfer function
EXPERIMENT NO. 8
THEORY -
A Bode plot is a graphical representation of the frequency response of a system. It is named after its
creator, Hendrik W. Bode. The Bode plot shows the magnitude and phase of the transfer function of a
system, plotted against frequency on a logarithmic scale.
The magnitude plot shows the amplitude ratio between the output and input signals, measured in
decibels (dB), as a function of frequency. The phase plot shows the phase shift between the output
and input signals, measured in degrees, as a function of frequency.
The Bode plot is useful for analyzing the frequency response of a system, including gain and phase
margins. The gain margin is the amount of gain that can be added to the system before it becomes
unstable, while the phase margin is the amount of phase shift that can be added before the system
becomes unstable.
The Bode plot can also help identify the system's poles and zeros, which are the frequencies at which
the system's transfer function has infinite or zero gain, respectively. The location of these poles and
zeros can provide insight into the system's behavior, such as its resonant frequencies and damping
characteristics.
Overall, the Bode plot is a powerful tool for understanding and designing systems in a variety of fields,
including control theory, signal processing, and electrical engineering.
CODE -
OUTPUT -
Figure - Bode plot of transfer function
EXPERIMENT - 9
THEORY -
A Nyquist plot is a graphical representation of the frequency response of a system, often used in
control theory. It plots the complex plane of the system's transfer function, where the real part of the
transfer function is plotted on the horizontal axis, and the imaginary part is plotted on the vertical axis.
The Nyquist plot is created by sweeping through a range of frequencies, and plotting the
corresponding points on the complex plane. By analyzing the shape of the Nyquist plot, one can gain
insights into the stability and performance of the system.
For example, the Nyquist plot can help identify whether a system is stable or unstable, by checking if
the plot encircles the point (-1,0) in the complex plane. If the plot encircles this point in a clockwise
direction, then the system is unstable. If it does not encircle this point, or if it encircles it in a
counterclockwise direction, then the system is stable.
The Nyquist plot can also be used to analyze the frequency response of the system, including gain
and phase margins. The gain margin is the amount of gain that can be added to the system before it
becomes unstable, while the phase margin is the amount of phase shift that can be added before the
system becomes unstable. These margins can be read off the Nyquist plot and used to optimize the
performance of the system.
CODE -
THEORY -
An overdamped system takes much more time to achieve a steady state value. An
underdamped system exhibits overshoot and also takes more time to achieve a steady state
value. A critically damped system achieves steady state value the fastest, and without
overshoot.
If δ > 1, the two roots are real and we have an over damped system.
If δ= 1, the system is known as a critically damped system.
CODE -
OUTPUT -