Materi Workshop MATLAB+WS
Materi Workshop MATLAB+WS
Materi Workshop MATLAB+WS
There are many different toolboxes available which extend the basic functions of
MATLAB into different application areas; in these tutorials, we will make extensive
use of the Control Systems Toolbox.
R(s) C(s)
R(s) C(s)
SYNTAX
EXAMPLE
EXAMPLE
EXAMPLE
FEEDBACK
• This function is used to generate transfer function of a negative feedback
system.
R(s) C(s)
-
SYNTAX
Sys = feedback(G,H)
•
ZPK
• Zpk function can be used to determine transfer function of a system that the poles, zeros
and amplifier gain are provided.
• Syntax:
Sys=zpk(Z,P,K)
With z is array containing zero(s), P is array containing pole(s) and k is the amplifier gain value
R(s) C(s)
note :
EXAMPLE
• Determine the transfer function of a system that has a zero on s=-1
and two poles on s=-2 and s=-4
PZMAP
• Pzmap function is used to graph the location of poles & zeros of a
system in s plane.
Syntax:
pzmap(G)
G: transfer function
EXAMPLE 1
• Determine the poles and zeros of this system
R(s) C(s)
CONTOH 2
R(s) C(s)
-
DIGITAL FILTER DESIGN
IIR & FIR
In signal processing, a finite impulse response (FIR) filter is a filter whose impulse response (or response to any
finite length input) is of finite duration, because it settles to zero in finite time. This is in contrast to
infinite impulse response (IIR) filters, which may have internal feedback and may continue to respond
indefinitely (usually decaying).
In this PPT :
IIR :
- Butterworth filter design
- Chebyshev filter design
FIR :
- Window-based FIR filter design
- Frequency sampling-based FIR filter design
IIR : Butter
Butterworth filter design : a type of signal processing filter designed to have a frequency response as
flat as possible in the passband
IIR : BUTTER
Syntax :
[b,a] = butter(n,Wn)
[b,a] = butter(n,Wn) returns the transfer function coefficients of an nth-order lowpass digital
Butterworth filter with normalized cutoff frequency Wn.
[b,a] = butter(n,Wn,ftype)
[b,a] = butter(n,Wn,ftype) designs a lowpass, highpass, bandpass, or bandstop Butterworth filter,
depending on the value of ftype and the number of elements of Wn. The resulting bandpass and bandstop
designs are of order 2n.
[z,p,k] = butter(___)
[z,p,k] = butter(___) designs a lowpass, highpass, bandpass, or bandstop digital Butterworth filter and
returns its zeros, poles, and gain. This syntax can include any of the input arguments in previous syntaxes.
IIR : BUTTER
Syntax :
[A,B,C,D] = butter(___)
[A,B,C,D] = butter(___) designs a lowpass, highpass, bandpass, or bandstop digital Butterworth filter
and returns the matrices that specify its state-space representation.
[___] = butter(___,'s')
[___] = butter(___,'s') designs a lowpass, highpass, bandpass, or bandstop analog Butterworth filter
with cutoff angular frequency Wn.
IIR : BUTTER
example1
6th-order lowpass Butterworth filter with a
cutoff frequency of 300 Hz, which, for data
sampled at 1000 Hz, corresponds to 0.6π
rad/sample. Plot its magnitude and phase
responses. Use it to filter a 1000-sample
random signal.
IIR : BUTTER
example2
6th-order Butterworth bandstop filter with
normalized edge frequencies of 0.2π and 0.6π
rad/sample. Plot its magnitude and phase
responses. Use it to filter random data.
IIR : CHEBY1, CHEBY 2
Chebyshev filters are analog or digital filters having a steeper roll-off than Butterworth filters, and
have passband ripple (type I) or stopband ripple (type II)
IIR : CHEBY1
[b,a] = cheby1(n,Rp,Wp) returns the transfer function coefficients of an nth-order lowpass digital
Chebyshev Type I filter with normalized passband edge frequency Wp and Rp decibels of peak-to-peak
passband ripple.
[b,a] = cheby1(n,Rp,Wp,ftype) designs a lowpass, highpass, bandpass, or bandstop Chebyshev Type I
filter, depending on the value of ftype and the number of elements of Wp. The resulting bandpass and
bandstop designs are of order 2n.
[z,p,k] = cheby1(___) designs a lowpass, highpass, bandpass, or bandstop digital Chebyshev Type I filter
and returns its zeros, poles, and gain. This syntax can include any of the input arguments in previous
syntaxes.
[A,B,C,D] = cheby1(___) designs a lowpass, highpass, bandpass, or bandstop digital Chebyshev Type I
filter and returns the matrices that specify its state-space representation.
[___] = cheby1(___,'s') designs a lowpass, highpass, bandpass, or bandstop analog Chebyshev Type I
filter with passband edge angular frequency Wp and Rp decibels of passband ripple.
CHEBY1 : EXAMPLE
Design a 8th-order Chebyshev Type I bandstop filter with normalized edge
frequencies of and rad/sample and 7 dB of passband ripple. Plot its magnitude and
phase responses. Use it to filter random data.
Note: Use fir1 for window-based standard lowpass, bandpass, highpass, bandstop, and
multiband configurations.
FIR2 : EXAMPLE
f = [0 0.6 0.6 1];
m = [1 1 0 0];
b1 = fir2(40,f,m);
[h1,w] = freqz(b1,1);
plot(f,m,w/pi,abs(h1))
xlabel('\omega / \pi')
lgs = {'Ideal','fir2 default'};
legend(lgs)
MODULATION AND DEMODULATION
MODULATION
Process of varying the properties of a specific waveform, also called the carrier
signal, using a modulating signal that contains information that is trying to be
transmitted.
DEMODULATION
Demodulating is used to recover the message signal from the modulated wave
MODULATION TYPES
R(s) C(s)
-
• Syntax:
rlocus(sys,K)or
rlocus(sys)
EXAMPLE 1
• Sketch the root locus graph of this system using the rlocus function
R(s) C(s)
-
EXAMPLE 2
• Sketch the root locus graph of this system using the rlocus function
R(s) C(s)
-
EXAMINING GAIN, FREQUENCY, ETC
BODE PLOT
• Bode plot is used to graph the frequency response of the system
• Bode plot could also be used to determine the system stability margin
• Syntax:
bode(sys) or
bode(sys1,sys2,……)
R(s) C(s)
EXAMPLE 2
• This unity gain feedback system has a plant with the following
transfer function G(s) = . Graph the bode plot of the open loop
transfer function then determine whether the system is stable or
not.
R(s)
20 C(s)
- 𝑠 (𝑠+2)(𝑠+5)
DETERMINING SYSTEM STABILITY
A system is stable when both the PM and GM of the open loop transfer function are positive.
Hence the system is stable
• GM = 36.9dB means that the system will remain stable until the
amplifier gain reach the maximum value of 36.9dB = 69.98 times
STEP RESPONSE
u(t)
• Step function is used to get system response when the input is a unit step function.
• Syntax:
step(sys) or
step(sys1,sys2, ….)
R(s) C(s)
EXAMPLE 2
• Graph the step response of this system for k=1,2 and 3. Store each of the transfer
function on a different variable then graph the step response on a single picture
• Examine the pole-zero map of the system on each k value.
• Examine the root locus of the system.
R(s) C(s)
-
THANKS!
Does anyone have any questions?
Keprof EL