Académique Documents
Professionnel Documents
Culture Documents
|
c
c
|
c
The name c stands for MATrixLABoratory. MATLAB is a
software package for high-performance numerical computation and
visualization . It provides an interactive environment with hundreds of
built-in functions for technical computation, graphics, and animation .
Best of all, it provides easy extensibility with its own high-level
programming language. Using the MATLAB product, you can solve
technical computing problems faster than with traditional programming
languages. The MATLAB development environment lets you develope
interactively analyze data, view the data files, and manage projects.
c
1) MATLAB¶s ease of use is its best feature. Also, it has a shallow
learning curve i.e. more learning with less effort .whereas the computer
algebra systems have a steep learning curve.
2) It is an high level language for technical computing.
3) MATLAB is often much faster at the calculations ±often as fast as C
or Fortran .
4) MATLAB beats everyone hands down in terms of ease of use,
availability of built-in functions, ease of programming, and speed. The
proof is the phenomenal growth of its users around the world in just a
few years.
5) MATLAB¶s built-in functions provide excellent tools for:
c
*It is an interpreted language for numerical computation. It allows one
to perform numerical calculations, and visualize the results without the
need for complicated and time consuming programming. MATLAB
allows its users to accurately solve problems, produce graphics easily
and produce code efficiently.
c
* There are limitations and restrictions on the use of the MATLAB
compiler. They vary from version to version. Regardless of the version,
script m-files cannot be converted into C codes or standalone
executables. You must first convert them into function m-files.
* Because MATLAB is an interpreted language, it can be slow, and poor
programming practices can make it unacceptably slow.
c
c
The general structure of the MATLAB environment is discussed below.
MATLAB desktop:
>>this is where MATLAB puts you when you launch it. The MATLAB
desktop by default consists of the following subwindows .
ë| á
This is the main window. It is
characterized by the MATLAB command prompt (>>). When you
launch the application program, MATLAB puts you in this
window. All commands, including those for running user-written
programs, are typed in this window at the MATLAB prompt. This
window further contains other smaller windows which are:
1)|á
this is where all your files rom the current
directory are listed. You can do file navigation here. You can
have several options of what you do with a file once you select
it (with a mouse click).
2)|
this sub-window lists all variables that you have
generated so far and shows their type and size. You can do
various things with these variables such as plotting, by clicking
on a variable and then using right button on the mouse to select
your option.
3)|á
all commands typed on the MATLAB
prompt in the command window get recorded, even across
multiple sessions, in this window. You can select a command
from this window with the mouse and execute it in the
command window by double clicking on it. You can also select
a set of commands from this window and create an m-file with
right click of the mouse.
ë|
The output of all graphics commands typed in
the command window are flushed to the graphics or figure
window, a separate gray window with (default) white background
color. The user can create as many figure windows as the system
memory will allow.
ë|
This is where you write, edit, create, and save
your own programs in files called M-files. You can use any text
editor to carry out these tasks. n most of systems, MATLAB
provides its own built-in editor. However you can use your own
editor by typing the standard file-editing command that you
normally use on your system.
c
To develop elementary signal function modules (m-files) for unit impulse, unit
step, exponential and unit ramp sequences.
c
x=input('left limit ')
y=input('right limit ')
t=-x:y
£
a=[zeros(1,x),ones(1,1),zeros(1,y)]
stem(t,a)
xlabel('t')
ylabel('a')
subplot(2,2,1)
b=[zeros(1,x),ones(1,y+1)]
stem(t,b)
xlabel('t')
ylabel('b')
subplot(2,2,2)
c=[zeros(1,x+1),1:y]
stem(t,c)
xlabel('t')
ylabel('c')
subplot(2,2,3)
x=
right limit 5
y=
t=
Columns 1 through 10
-5 -4 -3 -2 -1 0 1 2 3 4
Column 11
a=
Columns 1 through 10
0 0 0 0 0 1 0 0 0 0
Column 11
b=
Columns 1 through 10
0 0 0 0 0 1 1 1 1 1
Column 11
c=
Columns 1 through 10
0 0 0 0 0 0 1 2 3 4
Column 11
value of n 2
n=
d=
Columns 1 through 6
Columns 7 through 11
R R R R R
R R R R R
R R R R R
R R R R R
á
left limit 5
x=
5
right limit 5
y=
5
t=
Columns 1 through 10
-5 -4 -3 -2 -1 0 1 2 3 4
Column 11
5
value of n 0
n=
0
a=
Columns 1 through 10
InfInfInfInfInf 1 0 0 0 0
Column 11
0
R R R R R
á
left limit 5
x=
5
right limit 5
y=
5
t=
Columns 1 through 10
-5 -4 -3 -2 -1 0 1 2 3 4
Column 11
5
value of n -3
n=
-3
a=
Columns 1 through 6
-0.0041 0.0123 -0.0370 0.1111 -0.3333 1.0000
Columns 7 through 11
-3.0000 9.0000 -27.0000 81.0000 -243.0000
R
R
R
R
R
R R R R R
c
To develop program modules based on operation on sequences like signal shifting,
signal folding, signal addition and signal multiplication of
ë| unit step
ë| unit impulse and
ë| random signal
c
ë|
t=input('range ')
x1=[t>=0]
stem(t,x1)
xlabel('t')
ylabel('x1')
subplot(5,1,1)
k=input('delay ')
x2=[(t-k)>=0]
stem(t,x2)
xlabel('t')
ylabel('x2')
subplot(5,1,2)
£
t1=-fliplr(t)
x3=fliplr(x2)
stem(t1,x3)
xlabel('t1')
ylabel('x3')
subplot(5,1,3)
x4=x2+x3
stem(t,x4)
xlabel('t')
ylabel('x4')
subplot(5,1,4)
£ £
x5=x2.*x3
stem(t,x5)
xlabel('t')
ylabel('x5')
subplot(5,1,5)
á
range -4:5
t=
-4 -3 -2 -1 0 1 2 3 4 5
x1 =
0 0 0 0 1 1 1 1 1 1
delay 3
k=
3
x2 =
0 0 0 0 0 0 0 1 1 1
t1 =
-5 -4 -3 -2 -1 0 1 2 3 4
x3 =
1 1 1 0 0 0 0 0 0 0
x4 =
1 1 1 0 0 0 0 1 1 1
x5 =
0 0 0 0 0 0 0 0 0 0
R R R R
R R R R R
R R R R
R
R R R R
R R R R
ë| £
t=input('range ')
x1=[t==0]
stem(t,x1)
xlabel('t')
ylabel('x1')
subplot(5,1,1)
k=input('delay ')
x2=[(t-k)==0]
stem(t,x2)
xlabel('t')
ylabel('x2')
subplot(5,1,2)
£
t1=-fliplr(t)
x3=fliplr(x2)
stem(t1,x3)
xlabel('t1')
ylabel('x3')
subplot(5,1,3)
x4=x2+x3
stem(t,x4)
xlabel('t')
ylabel('x4')
subplot(5,1,4)
£ £
x5=x2.*x3
stem(t,x5)
xlabel('t')
ylabel('x5')
subplot(5,1,5)
á
range -4:5
t=
-4 -3 -2 -1 0 1 2 3 4 5
x1 =
0 0 0 0 1 0 0 0 0 0
delay 3
k=
3
x2 =
0 0 0 0 0 0 0 1 0 0
t1 =
-5 -4 -3 -2 -1 0 1 2 3 4
x3 =
0 0 1 0 0 0 0 0 0 0
x4 =
0 0 1 0 0 0 0 1 0 0
x5 =
0 0 0 0 0 0 0 0 0 0
R R R R
R R R R R
R R R R
R
R R R R
R R R R
£
t=input('range')
x1=input('enter sequence')
stem(t,x1)
xlabel('t')
ylabel('x1')
subplot(5,1,1)
k=input('delay')
t1=t-k
stem(t1,x1)
xlabel('t1')
ylabel('x1')
subplot(5,1,2)
£
t2=-fliplr(t)
x2=fliplr(x1)
stem(t2,x2)
xlabel('t2')
ylabel('x2')
subplot(5,1,3)
x3=x1+x2
stem(t,x3)
xlabel('t')
ylabel('x3')
subplot(5,1,4)
£ £
x4=x1.*x2
stem(t,x4)
xlabel('t')
ylabel('x4')
subplot(5,1,5)
á
range-4:5
t=
-4 -3 -2 -1 0 1 2 3 4 5
enter sequence[1,3,2,4,5,4,3,2,3,2]
x1 =
1 3 2 4 5 4 3 2 3 2
delay3
k=
3
t1 =
-7 -6 -5 -4 -3 -2 -1 0 1 2
t2 =
-5 -4 -3 -2 -1 0 1 2 3 4
x2 =
2 3 2 3 4 5 4 2 3 1
x3 =
3 6 4 7 9 9 7 4 6 3
x4 =
2 9 4 12 20 20 12 4 9 2
R R R R R R R
R R R R R
R R R R
R R R R
R R R R
c
To calculate and plot convolution of two causal, anti-causal and two-sided
sequences.
c
|
m1=input('left limit of 1st ')
n1=input('right limit of 1st ')
t1=-m1:n1
x1=input('enter 1st sequence ')
stem(t1,x1)
xlabel('t1')
ylabel('x1')
subplot(3,1,1)
m2=input('left limit of 2nd ')
n2=input('right limit of 2nd ')
t2=-m2:n2
x2=input('enter 2nd sequence ')
stem(t2,x2)
xlabel('t2')
ylabel('x2')
subplot(3,1,2)
l=m1+m2
r=n1+n2
t=-l:r
y=conv(x1,x2)
stem(t,y)
xlabel('t')
ylabel('y')
subplot(3,1,3)
ácc
£
left limit of 1st 0
m1 =
0
right limit of 1st 4
n1 =
4
t1 =
0 1 2 3 4
enter 1st sequence [2,3,1,2,1]
x1 =
2 3 1 2 1
left limit of 2nd 0
m2 =
0
right limit of 2nd 6
n2 =
6
t2 =
0 1 2 3 4 5 6
enter 2nd sequence [2,1,3,2,3,2,1]
x2 =
2 1 3 2 3 2 1
l=
0
r=
10
t=
0 1 2 3 4 5 6 7 8 9 10
y=
4 8 11 18 19 22 18 13 8 4 1
u
u
u
u
u
u
u
u
u u
£
l=
9
r=
-3
t=
-9 -8 -7 -6 -5 -4 -3
y=
2 9 14 13 11 5 2
R R R R R R R
R R R
R R R R
R R R R R R R
R R R R
R R R
R R
c
WAP to determine:
1. Cross Correlation
2. Auto Correlation
of any sequence.
c
t=input('nter range')
x=input('nter 1st sequence')
y=input('nter 2nd sequence')
%cross-correlation
m=xcorr(x,y)
subplot(2,1,1)
stem(m)
xlabel('t')
ylabel('m')
%auto-correlation
n=xcorr(x,x)
subplot(2,1,2)
stem(n)
xlabel('t')
ylabel('n')|
|
á
nter range-2:3
t=
-2 -1 0 1 2 3
m=
2.0000 5.0000 11.0000 12.0000 20.0000 24.0000 26.0000 26.0000
13.0000 17.0000 12.0000
n=
6 7 13 16 16 28 16 16 13 7 6
@
@ @ @@
@
@ @ @@
c
WAP to plot poles and zeros of Transfer function and also check the stability of
the system.
c
num=input('enter coefficients of numerator')
den=input('enter coefficients of denominator')
tf(num,den)
[z,p,k]=tf2zp(num,den)
zplane(num,den)
if abs(p)<=1
disp('stable')
else
disp('unstable')
end
á
enter coefficients of numerator[2,1,3,2]
num =
2 1 3 2
2 3 1 3
Transfer function:
2 s^3 + s^2 + 3 s + 2
---------------------
2 s^3 + 3 s^2 + s + 3
z=
0.0658 + 1.2565i
0.0658 - 1.2565i
-0.6316
p=
-1.7174
0.1087 + 0.9282i
0.1087 - 0.9282i
k=
1
unstable
R
R
[]
c
WAP to calculate the twiddle factor for 2, 4, 8.
c
n=input('length')
dftmtx(n)
á
length2
n=
2
ans =
1 1
1| -1
length4
n=
4
ans =
1.0000 1.0000 1.0000 1.0000
1.0000 0 - 1.0000i -1.0000 0 + 1.0000i
1.0000 -1.0000 1.0000 -1.0000
1.0000 0 + 1.0000i -1.0000 0 - 1.0000i
length8
n=
8
ans =
1.0000 1.0000 1.0000 1.0000 1.0000
1.0000 1.0000 1.0000
1.0000 0.7071 - 0.7071i 0 - 1.0000i -0.7071 - 0.7071i -1.0000
-0.7071 + 0.7071i 0 + 1.0000i 0.7071 + 0.7071i
1.0000 0 - 1.0000i -1.0000 0 + 1.0000i 1.0000
0 - 1.0000i -1.0000 0 + 1.0000i
nter Length2
n=
2
y=
3 1
z=
2| 1
nter any sequence[2,1,3,2,4,1]
x=
2 1 3 2 4 1
nter Length4
n=
4
y=
8.0000 -1.0000 + 1.0000i 2.0000 -1.0000 - 1.0000i
z=
2 1 3 2
nter any sequence[2,1,3,2,4,1]
x=
2 1 3 2 4 1
nter Length8
n=
8
y=
13.0000 -3.4142 - 4.4142i 3.0000 -0.5858 + 1.5858i 5.0000
-0.5858 - 1.5858i 3.0000 -3.4142 + 4.4142i
z=
2 1 3 2 4 1 0 0
c
WAP to calculate zero padding between two sequences.
c
x1=input('nter 1st sequence')
x2=input('nter 2nd sequence')
a=length(x1)
b=length(x2)
if(a==b)
x1=[x1]
x2=[x2]
elseif(a>b)
n=a-b
x1=[x1]
x2=[x2,zeros(1,n)]
else
n=b-a
x1=[x1,zeros(1,n)]
x2=[x2]
end
|
á
nter 1st sequence[1,2,3,1,2]
x1 =
1 2 3 1 2
nter 2nd sequence[3,2,1,3]
x2 =
3 2 1 3
a=
5
b=
4
n=
1
x1 =
1 2 3 1 2
x2 =
3 2 1 3 0
c
WAP to calculate circular convolution using FT and I FT method.
c
x1=input('nter 1st sequence')
x2=input('nter 2nd sequence')
a=length(x1)
b=length(x2)
if(a==b)
x1=[x1]
x2=[x2]
p=fft(x1)
q=fft(x2)
r=p.*q
s=ifft(r)
elseif(a>b)
n=a-b
x1=[x1]
x2=[x2,zeros(1,n)]
p=fft(x1)
q=fft(x2)
r=p.*q
s=ifft(r)
else
n=b-a
x1=[x1,zeros(1,n)]
x2=[x2]
p=fft(x1)
q=fft(x2)
r=p.*q
s=ifft(r)
end
á
nter 1st sequence[1,3,2,3]
x1 =
1 3 2 3
nter 2nd sequence[1,2,3,1,2]
x2 =
1 2 3 1 2
a=
4
b=
5
n=
1
x1 =
1 3 2 3 0
x2 =
1 2 3 1 2
p=
9.0000 -2.1180 - 2.2654i 0.1180 - 2.7144i 0.1180 + 2.7144i -2.1180
+ 2.2654i
q=
9.0000 -1.0000 - 1.1756i -1.0000 + 1.9021i -1.0000 - 1.9021i -
1.0000 + 1.1756i
r=
81.0000 -0.5451 + 4.7553i 5.0451 + 2.9389i 5.0451 - 2.9389i -
0.5451 - 4.7553i
s=
18 12 17 17 17
c
WAP to calculate circular convolution using function available in toolbox.
c
x1=input('nter 1st sequence')
x2=input('nter 2nd sequence')
a=length(x1)
b=length(x2)
if(a==b)
c=cconv(x1,x2,a)
elseif(a>b)
c=cconv(x1,x2,a)
else
c=cconv(x1,x1,b)
end
á
nter 1st sequence[2,1,3,2,1]
x1 =
2 1 3 2 1
x2 =
2 1 3 2
a=
5
b=
4
c=
17 11 15 14 15
c
WAP to:-
1)| Plot poles and zeros for any transfer function.
2)| Calculate the roots of numerator and denominator of any transfer function.
3)| From the roots calculate polynomial coefficients of numerator and denominator.
4)| Calculate the frequency response of this transfer function:
ë| Magnitude response.
ë| Phase response.
c
á
nter Coefficient of numerator [1,2,3,1,2]
n=
1 2 3 1 2
Transfer function:
s^4 + 2 s^3 + 3 s^2 + s + 2
---------------------------
s^4 + 2 s^3 + s^2 + 2 s + 3
z=
-1.1097 + 1.2377i
-1.1097 - 1.2377i
0.1097 + 0.8436i
0.1097 - 0.8436i
p=
0.4436 + 1.0818i
0.4436 - 1.0818i
-1.4436 + 0.3324i
-1.4436 - 0.3324i
k=
1
r1 =
-1.1097 + 1.2377i
-1.1097 - 1.2377i
0.1097 + 0.8436i
0.1097 - 0.8436i
r2 =
0.4436 + 1.0818i
0.4436 - 1.0818i
-1.4436 + 0.3324i
-1.4436 - 0.3324i
p1 =
1.0000 2.0000 3.0000 1.0000 2.0000
p2 =
1.0000 2.0000 1.0000 2.0000 3.0000
R
R R R
!
R
R
c
WAP to calculate inverse z-transform for any transfer function by power series
expansion method.
ë|
£ £ £
c
n=input('nter Coefficient of numerator ')
d=input('nter Coefficient of denominator ')
a=length(n)
b=length(d)
if(a>b)
[q,r]=deconv(n,d)
else
x=4
n=[n,zeros(1,x-1)]
[q,r]=deconv(n,d)
end
á
nter Coefficient of numerator [1 2 3 1 2]
n=
1 2 3 1 2
nter Coefficient of denominator [1 2 1 2 3]
d=
1 2 1 2 3
a=
5
b=
5
x=
4
n=
1 2 3 1 2 0 0 0
q=
1 0 2 -5
r=
0 0 0 0 7 1 4 15
ë|
£ £
c
n1=input('nter Coefficient of 1st sequece of numerator ')
n2=input('nter Coefficient of 2nd sequece of numerator ')
n3=input('nter Coefficient of 3rd sequece of numerator ')
n=[n1;n2;n3]
d=[d1;d2;d3]
[num,den]=sos2tf([n,d])
a=length(num)
b=length(den)
if(a>b)
[q,r]=deconv(num,den)
else
x=4
num=[num,zeros(1,x-1)]
[q,r]=deconv(num,den)
end
á
nter Coefficient of 1st sequece of numerator [1,2,3]
n1 =
1 2 3
nter Coefficient of 2nd sequece of numerator [1,1,1]
n2 =
1 1 1
nter Coefficient of 3rd sequece of numerator [2,1,2]
n3 =
2 1 2
n=
1 2 3
1 1 1
2 1 2
d=
1 2 3
3 2 1
1 1 1
num =
2 7 17 22 23 13 6
den =
3 11 25 30 25 11 3
a=
7
b=
7
x=
4
num =
2 7 17 22 23 13 6 0 0 0
q=
0.6667 -0.1111 0.5185 -0.3086
r=
Columns 1 through 9
Column 10
0.9259
c
WAP to design magnitude response for rectangular, hamming, hanning,
triangular, blackman and Kaiser window.
c
n=input('order of filter ')
b=input('value of beta ')
w1=window(@rectwin,n)
w2=window(@hamming,n)
w3=window(@hann,n)
w4=window(@triang,n)
w5=window(@blackman,n)
w6=window(@kaiser,n)
plot(1:n,[w1,w2,w3,w4,w5,w6]);axis([1 n 0 1])
legend('rectwin','hamming','hann','triang','blackman','kaiser')
á
order of filter 5
n=
5
value of beta 4
b=
4
w1 =
1
1
1
1
1
w2 =
0.0800
0.5400
1.0000
0.5400
0.0800
w3 =
0
0.5000
1.0000
0.5000
0
w4 =
0.3333
0.6667
1.0000
0.6667
0.3333
w5 =
-0.0000
0.3400
1.0000
0.3400
-0.0000
w6 =
0.9403
0.9849
1.0000
0.9849
0.9403
@
@ @
c
WAP to designa FIR filter by using rectangular, hamming, hanning, triangular,
blackman and Kaiser windows for:
ë| LPF
ë| HPF
ë| BPF
ë| BSF
c
ë|
|
£
n=input('order of filter ')
w=input('cut off frequency')
b=fir1(n,w,rectwin(n+1))
freqz(b,1)
|
u
u
! "#$
u
uu
u u u u u u u u u u
º
|
n=input('order of filter ')
w=input('cut off frequency')
b=fir1(n,w,hamming(n+1))
freqz(b,1)
u
! "#$
u
u
uu
u
u u u u u u u u u u
º
|
n=input('order of filter ')
w=input('cut off frequency')
b=fir1(n,w,hann(n+1))
freqz(b,1)
|
u
! "# $
u
u u
u
u u u u u u u u u u
º
| £
n=input('order of filter ')
w=input('cut off frequency')
b=fir1(n,w,triang(n+1))
freqz(b,1)
u
! " # $
u
u
u
u u u u u u u u u u
º
| £
n=input('order of filter ')
w=input('cut off frequency')
b=fir1(n,w,blackman(n+1))
freqz(b,1)
u
R u
R uu
R u
u u u u u u u u u u
º
| ÷
n=input('order of filter ')
w=input('cut off frequency')
d=input('value of beta ')
b=fir1(n,w,kaiser(n+1,d))
freqz(b,1)
u
R u
R uu
u u u
u u u u
u u u
º
ë|
|
£
n=input('order of filter ')
w=input('cut off frequency')
b=fir1(n,w,'high',rectwin(n+1))
freqz(b,1)
! "# $
u
u
u u
u u u u u u u u u u
º
|
n=input('order of filter ')
w=input('cut off frequency')
b=fir1(n,w,'high',hamming(n+1))
freqz(b,1)
! "# $
! " #
º
|
n=input('order of filter ')
w=input('cut off frequency')
b=fir1(n,w,'high',hann(n+1))
freqz(b,1)
! "# $
! " # º
| £
n=input('order of filter ')
w=input('cut off frequency')
b=fir1(n,w,'high',triang(n+1))
freqz(b,1)
u
! "#$
u
u
u
u
u u u u u u u u u u
º
| £
n=input('order of filter ')
w=input('cut off frequency')
b=fir1(n,w,'high',blackman(n+1))
freqz(b,1)
u
!"#$
u
uu
u
u u u u u u u u u u
º
| ÷
n=input('order of filter ')
w=input('cut off frequency')
d=input('value of beta ')
b=fir1(n,w,'high',kaiser(n+1,d))
freqz(b,1)
u
! " # $
u
u u
u u u u u u u u u u
º
ë|
|
£
n=input('order of filter ')
w1=input('1st cut off frequency')
w2=input('2nd cut off frequency')
w=[w1 w2]
b=fir1(n,w,'bandpass',rectwin(n+1))
freqz(b,1)
! "# $
u
u
u u
u u u u u u u u u u
º
|
n=input('order of filter ')
w1=input('1st cut off frequency')
w2=input('2nd cut off frequency')
w=[w1 w2]
b=fir1(n,w,'bandpass',hamming(n+1))
freqz(b,1)
! "# $
u
u
u u
u
u u u u u u u u u u
º
|
n=input('order of filter ')
w1=input('1st cut off frequency')
w2=input('2nd cut off frequency')
w=[w1 w2]
b=fir1(n,w,'bandpass',hann(n+1))
freqz(b,1)
u
! "# $
u
u
u u
u
u u u u u u u u u u
º
| £
n=input('order of filter ')
w1=input('1st cut off frequency')
w2=input('2nd cut off frequency')
w=[w1 w2]
b=fir1(n,w,'bandpass',triang(n+1))
freqz(b,1)
|
u
!"#$
u
u
u
u
u u u u u u u u u u
º
| £
n=input('order of filter ')
w1=input('1st cut off frequency')
w2=input('2nd cut off frequency')
w=[w1 w2]
b=fir1(n,w,'bandpass',blackman(n+1))
freqz(b,1)
u
!"#$
u
uu
u
u u u u u u u u u u
º
| ÷
n=input('order of filter ')
w1=input('1st cut off frequency')
w2=input('2nd cut off frequency')
d=input('value of beta ')
w=[w1 w2]
b=fir1(n,w,'bandpass',kaiser(n+1,d))
freqz(b,1)
u
! "# $
u
u u
u
u u u u u u u u u u
º
ë|
|
£
n=input('order of filter ')
w1=input('1st cut off frequency')
w2=input('2nd cut off frequency')
w=[w1 w2]
b=fir1(n,w,'stop',rectwin(n+1))
freqz(b,1)
$
*
! "#$
/ *$
/ &$ $ $ $ $ ' $ ( $ ) $ $ + $ , $ - $ .
%& % % % %* % % % % &
01
2 3
45 6 º
|
n=input('order of filter ')
w1=input('1st cut off frequency')
w2=input('2nd cut off frequency')
w=[w1 w2]
b=fir1(n,w,'stop ',hamming(n+1))
freqz(b,1)
u
! "#$
u
uu
u u u u u u u u u u
º
|
n=input('order of filter ')
w1=input('1st cut off frequency')
w2=input('2nd cut off frequency')
w=[w1 w2]
b=fir1(n,w,'stop ',hann(n+1))
freqz(b,1)
u
! "# $
u
u u
u
u u u u u u u u u u
º
| £
n=input('order of filter ')
w1=input('1st cut off frequency')
w2=input('2nd cut off frequency')
w=[w1 w2]
b=fir1(n,w,'stop ',triang(n+1))
freqz(b,1)
|
! "# $
u
u
u u
u
u u u u u u u u u u
º
| £
n=input('order of filter ')
w1=input('1st cut off frequency')
w2=input('2nd cut off frequency')
w=[w1 w2]
b=fir1(n,w,'stop ',blackman(n+1))
freqz(b,1)
! "# $
u
u
u u
u
u u u u u u u u u u
º
| ÷
n=input('order of filter ')
w1=input('1st cut off frequency')
w2=input('2nd cut off frequency')
d=input('value of beta ')
w=[w1 w2]
b=fir1(n,w,' stop ',kaiser(n+1,d))
freqz(b,1)
u
!"#$
u
uu
u u u u u u u u u u
º
c
WAP to convert analog filter to digital filter by using:
ë| IIM method
ë| BLT method.
c
|cc
n=input('nter Îumerator ')
d=input('nter enominator ')
fs=input('Sampling Frequency ')
[b,a]=impinvar(d,n,fs)
á
nter Îumerator [1,2,1,2]
n=
1 2 1 2
Sampling Frequency .6
fs =
0.6000
b=
-1.6667 0.5136 -2.0594 -0.1189
a=
1.0000 0.1558 0.9932 -0.0357
|c
n=input('nter Îumerator ')
d=input('nter enominator ')
fs=input('Sampling Frequency ')
[b,a]=bilinear(d,n,fs)
á
nter Îumerator [1,2,1,2]
n=
1 2 1 2
Sampling Frequency .6
fs =
0.6000
b=
1.3443 -0.2828 1.4508 -0.4631
a=
1.0000 -0.1107 0.9098 0.2500
c
WAP to design a Butterworth LPF, HPF, BPF, BSF when passband is 4db and
stopband attenuation is 30db.
ë| For LPF and HPF:
Passband frequency=0.2rad/sec.
Stopband frequency=0.4rad/sec.
ë| For BPF and BSF:
Passband frequency=0.2rad/sec to 0.7rad/sec.
Stopband frequency=0.1rad/sec to 0.8rad/sec.
c
|
Wp=0.2
Ws=0.4
Rp=4
Rs=30
[Î,Wn]=buttord(Wp,Ws,Rp,Rs)
[b,a]=butter(Î,Wn,'low')
freqz(b,a)
á
Wp =
0.2000
Ws =
0.4000
Rp =
4
Rs =
30
Î=
5
Wn =
0.2223
b=
0.0020 0.0100 0.0201 0.0201 0.0100 0.0020
a=
1.0000 -2.7513 3.3365 -2.1353 0.7128 -0.0983
uu
$ #%&
uu
uu
uu
u u u u u u u u u u
º
u
! "#
uu
uu
uu
u u u u u u u u u u
º
|
Wp=0.2
Ws=0.4
Rp=4
Rs=30
[Î,Wn]=buttord(Wp,Ws,Rp,Rs)
[b,a]=butter(Î,Wn,'high')
freqz(b,a)
á
Wp =
0.2000
Ws =
0.4000
Rp =
4
Rs =
30
Î=
5
Wn =
0.2223
b=
0.3136 -1.5678 3.1357 -3.1357 1.5678 -0.3136
a=
1.0000 -2.7513 3.3365 -2.1353 0.7128 -0.0983
u
uu
uu
uu
u u u u u u u u u u
8 º
uu
uu
uu
u u u u u u u u u u
7 º
|
|
Wp=[0.2 0.7]
Ws=[0.1 0.8]
Rp=4
Rs=30
[Î,Wn]=buttord(Wp,Ws,Rp,Rs)
[b,a]=butter(Î,Wn,'bandpass')
freqz(b,a)
á
Wp =
0.2000 0.7000
Ws =
0.1000 0.8000
Rp =
4
Rs =
30
Î=
6
Wn =
0.2019 0.6974
b=
Columns 1 through 12
0.0283 0 -0.1700 0 0.4250 0 -0.5667 0 0.4250 0
-0.1700 0
Column 13
0.0283
a=
Columns 1 through 12
1.0000 -1.3394 0.8398 -0.6611 1.1629 -0.8259 0.3178 -0.1708
0.1677 -0.0584 0.0090 -0.0027
Column 13
0.0018
u
$ #%&
uu
uu
uu
uu
u u u u u u u u u u
º
uu
! "#
uu
uuu
u u u u u u u u u u
º
|
Wp=[0.2 0.7]
Ws=[0.1 0.8]
Rp=4
Rs=30
[Î,Wn]=buttord(Wp,Ws,Rp,Rs)
[b,a]=butter(Î,Wn,'stop')
freqz(b,a)
|
á
Wp =
0.2000 0.7000
Ws =
0.1000 0.8000
Rp =
4
Rs =
30
Î=
6
Wn =
0.2019 0.6974
b=
Columns 1 through 12
0.0309 -0.0820 0.2760 -0.4635 0.8438 -0.9836 1.1976 -0.9836
0.8438 -0.4635 0.2760 -0.0820
Column 13
0.0309
a=
Columns 1 through 12
1.0000 -1.3394 0.8398 -0.6611 1.1629 -0.8259 0.3178 -0.1708
0.1677 -0.0584 0.0090 -0.0027
Column 13
0.0018
u
^Y
W uu
V
U
W
]
\ uu
[
X
S
Z uu
uu
u u u : u ; u < u u > u ? u @ u A
L
C D EF G
EHIEJK M º
DF NDC OEP
u
YT
U
U
X uu
U
W
V
U
T
S uuu
R
Q
B9= uu
u u 9 u : u ; u < u = u > u ? u @ u A 9
L
C D EF G
EHIEJK M º
DF NDC OEP