signals & system using matlab - rit pampady
DESCRIPTION
PPT on Matlab Commands used in SASTRANSCRIPT
“FEAR OF THE LORD IS THE BEGINNING OF WISDOM”
SIGNALS & SYSTEM ANALYSIS USING MATLAB
By
Mr. Anish BennyAsst. Professor
SIGNALS & SYSTEM
• Signals and systems deal with various types of signals and the analysis of the system.• Signals can be elementary type or derived type. • Elementary signals are impulse signal, step signal
and ramp signal.• Derived signals are sinusoidal signals,
exponential signals, pulse etc.• Matlab can be used for generating all types of
signals.• Signals and systems toolbox is employed for
theses purpose
KITES - 2014, RIT PAMPADY
SYSTEM
• A is an interconnection of components forming a particular configuration to provide a desired system response
Mobile phone
Computer
Robotic arm
Automobile cruise control system etc.
KITES - 2014, RIT PAMPADY
Basic Signals & System Components
System
- The device which will generate response according to the given input
ProcessSystem Input
signal
Output
CONCEPT OF A SYSTEM
KITES - 2014, RIT PAMPADY
SIGNALS & SYSTEM MODELLING
• Time domain modeling is done on both the signals and system to get the mathematical equation.
• Time domain model (both continuous and discrete)is needed for further analysis.
• By applying a frequency domain transformation on the above time domain model will result in Transfer Function (TF) of the system and frequency spectrum of the signal.
• By using the model of a system we can analyze the system for various properties like linearity, time invariance, stability etc.
KITES - 2014, RIT PAMPADY
STEP SIGNAL
KITES - 2014, RIT PAMPADY
VARIOUS FORMS OF STEP SIGNAL
KITES - 2014, RIT PAMPADY
EXAMPLE
KITES - 2014, RIT PAMPADY
EXAMPLE
KITES - 2014, RIT PAMPADY
RAMP FUNCTION
KITES - 2014, RIT PAMPADY
IMPULSE SIGNAL
KITES - 2014, RIT PAMPADY
EXAMPLE – SYSTEM MODELING
KITES - 2014, RIT PAMPADY
• Find the model of the system? Take v1(t) as input and v2(t) as the output.
• Solution
EXAMPLE – CIRCUIT MODELING
• Find the model of the system? Take v1(t) as input and v2(t) as the output.
• Solution
KITES - 2014, RIT PAMPADY
TRANSFER FUNCTION OF THE MODEL
• Case 1• By applying Laplace transform we get,
• RCSV2(s)+V2 (s) = V1 (s)
• Output/Input = V2 (s)/ V1 (s) = 1/(SRC + 1)
• Case 2• By applying Laplace transform we get,
• LCS2V2 (s)+RCSV2(s)+V2 (s) = V1 (s)
• Output/Input = V2 (s)/ V1 (s) = 1/(S2LC + SRC + 1)
KITES - 2014, RIT PAMPADY
MATLAB COMMANDS
• ss - Specify state-space models or convert LTI model to state space
• tf - Create or convert to transfer function model• zpk - Create or convert to zero-pole-gain model• bodeplot - Plot Bode frequency response and return plot
handle• impulseplot - Plot impulse response and return plot handle• pzplot - Plot pole-zero map of LTI model and return plot
handle• stepplot - Plot step response of LTI systems and return
plot handle
KITES - 2014, RIT PAMPADY
• conv - Convolution and polynomial multiplication• deconv - Deconvolution and polynomial division• fourier – Finds the Fourier transform• ifourier - Inverse Fourier transform• laplace – Finds the Laplace transform• ilaplace - Inverse Laplace transform• ztrans – Finds the Z transform• iztrans - Inverse Z transform• sawtooth - Sawtooth or triangle wave• square - Square wave• gensig - Generate test input signals for lsim
KITES - 2014, RIT PAMPADY
MATLAB COMMANDS
• allmargin - All crossover frequencies and corresponding stability margins
• bode - Bode diagram of frequency response• bodemag - Bode magnitude response of LTI models• evalfr - Evaluate frequency response at given frequency• freqresp - Evaluate frequency response over frequency
grid• frd - Create or convert to frequency-response data models• margin - Gain and phase margins and associated crossover
frequencies• impulse - Impulse response of LTI model• step - Step response of LTI systems
KITES - 2014, RIT PAMPADY
MATLAB COMMANDS
MATLAB COMMANDS
• bandwidth - Frequency response bandwidth• lti/order - LTI model order• pole - Compute poles of LTI system• zero - Transmission zeros of LTI model• pzmap - Compute pole-zero map of LTI models• ss2tf - Convert state-space filter parameters to transfer
function form• tf2ss - Convert transfer function filter parameters to state-
space form• feedback - Feedback connection of two LTI models
KITES - 2014, RIT PAMPADY
CONTINUOUS TIME SYSTEM ANALYSIS
• Transfer Function Representation• Time Simulations• Frequency Response Plots• Control Design • State Space Representation
TRANSFER FUNCTION REPRESENTATION
• Tf2zp• Zp2tf• Feedback• Parallel• series
CONT…
• Transfer functions are defined in MATLAB by storing the coefficients of the numerator and the denominator in vectors. Given a continuous-time transfer function
B(s) H(s) = --------- A(s)
CONT…
• Where B(s) = bMsM+bM-1sM-1+…+b0
and A(s) = aNsN+aN-1sN-1+…+a0
Store the coefficients of B(s) and A(s) in the vectors
num = [bM bM-1 … b0]
den = [aN aN-1 … a0]
EXAMPLE
5s+6 H(s) = ---------------- s3+10s2+5• num = [5 6]; • den = [1 10 0 5];
• all coefficients must be included in the vector, even zero coefficients
CONT…
• To find the zeros, poles and gain of a transfer function from the vectors num and den which contain the coefficients of the numerator and denominator polynomials:
[z,p,k] = tf2zp(num,den)
EXAMPLE
• num = [5 6]; • den = [1 10 0 5];
• [z,p,k] = tf2zp(num,den)
• z = -1.2000• p = -10.0495 0.0248+0.7049i 0.0248-
0.7049i• k = 5
EXAMPLE CONT…
(s-z1)(s-z2)...(s-zn)
H(s) = K -------------------------- (s-p1)(s-p2)...(s-pn)
5*(s+1.2) ---------------------------------------------------------- (s+10.0495)(s-{0.0248+0.7049i})(s-{0.0248-
0.7049i})
CONT…
• To find the numerator and denominator polynomials from z, p, and k:
[num,den] = zp2tf(z,p,k)
• To reduce the general feedback system to a single transfer function: T(s) = G(s)/(1+G(s)H(s)) [numT,denT]=feedback(numG,denG,numH,denH);
CONT…
• To reduce the series system to a single transfer function, T(s) = G(s)H(s)
[numT,denT] = series(numG,denG,numH,denH);• To reduce the parallel system to a single transfer
function, T(s) = G(s) + H(s)[numT,denT] = parallel(numG,denG,numH,denH);
TIME SIMULATIONS
• residue • Step• Impulse• lsim
CONT…
• [R,P,K] = residue (B,A) finds the residues, poles and direct term of a partial fraction expansion of the ratio of two polynomials B(s)/A(s)• The residues are stored in r, the corresponding
poles are stored in p, and the gain is stored in k.
EXAMPLE
• If the ratio of two polynomials is expressed as• b(s) 5s3+3s2-2s+7 ------- = ------------------- a(s) -4s3+8s+3
• b = [ 5 3 -2 7]• a = [-4 0 8 3]
EXAMPLE CONT…
• r = -1.4167 -0.6653 1.3320• p = 1.5737 -1.1644 -0.4093• k = -1.2500
• B(s) R(1) R(2) R(n)• ------ = -------- + --------- + ... + --------- + K(s)• A(s) s - P(1) s - P(2) s - P(n)
FIND THE RESPONSE OF A SYSTEM TO A PARTICULAR INPUT
• First store the numerator and denominator of the transfer function in num and den, respectively.• To plot the step response: step(num,den)• To plot the impulse response: impulse(num,den)
CONT…
• For the response to an arbitrary input, use the command lsim (linear simulation)• Create a vector t which contains the time values
in seconds t = a:b:c;• Define the input x as a function of time, for
example, a ramp is defined as x = t lsim(num,den,x,t);
FREQUENCY RESPONSE PLOTS
• Freqs• Bode• Logspace• Log10• Semilogx
CONT…
• To compute the frequency response H of a transfer function, store the numerator and denominator of the transfer function in the vectors num and den.
• Define a vector w that contains the frequencies for which H) is to be computed, for example w = a:b:c where a is the lowest frequency, c is the highest frequency and b is the increment in frequency.
H = freqs(num,den,w)
CONT…
• To draw a Bode plot of a transfer function which has been stored in the vectors num and den:
bode(num,den)
CONT…
• To customize the plot, first define the vector w which contains the frequencies at which the Bode plot will be calculated.
• Since w should be defined on a log scale, the command logspace is used.
• For example, to make a Bode plot ranging in frequencies from 0.1 to 100, define w by
w = logspace(-1,2);• The magnitude and phase information for the Bode
plot can then be found by: [mag,phase] = bode(num,den,w);
CONT…
• To plot the magnitude in decibels, convert mag using the following command:
magdb = 20*log10(mag);• To plot the results on a semilog scale where the
y-axis is linear and the x-axis is logarithmic: semilogx(w,magdb)• For the log-magnitude plot : semilogx(w,phase)
VERY SHORT SIMULINK TUTORIAL
• In the Matlab command window write simulink.• The window that has opened is the Simulink Library
Browser. • It is used to choose various Simulink modules to use in your
simulation.
• From this window, choose the File menu, and then New (Model). • Now we have a blank window, in which we will build our model. • This blank window and the library browser window, will be the
windows we’ll work with.
• We choose components from the library browser, and then drag them to our work window. • We’ll use only the Simulink library (also called toolbox) for now.
KITES - 2014, RIT PAMPADY
SIMULINK TUTORIAL
As we can see, the Simulink library is divided into several categories:
1. Continuous – Provides functions for continuous time, such as integration, derivative, etc.
2. Discrete – Provides functions for discrete time.
3. Functions & Tables – Just what the name says.
4. Math – Simple math functions.
5. Nonlinear – Several non-linear functions, such as switches, limiters, etc.
6. Signals & Systems – Components that work with signals.
7. Sinks – Components that handle the outputs of the system (e.g. display it on the screen).
8. Sources – Components that generate source signals for the system.
KITES - 2014, RIT PAMPADY
EXAMPLE OF SIMULINK
KITES - 2014, RIT PAMPADY
Two main libraries for manipulating signals in Simulink:
• Sources: generate a signal• Sink: display, read or store a signal
EXAMPLE OF SIMULINK
KITES - 2014, RIT PAMPADY
EXAMPLE OF SIMULINK
KITES - 2014, RIT PAMPADY