DSP Report 2014
DSP Report 2014
33333333333333DSP LAB
SUBJECT: DSP LAB
SEM: V
Branch: E&CE
RYMEC, BLY
Page 1
Dept of E&CE
PART-A
DSP PROGRAMS USING MAT LAB
RYMEC, BLY
Page 2
Dept of E&CE
RYMEC, BLY
Page 3
Dept of E&CE
Plot:
RYMEC, BLY
Page 4
Dept of E&CE
Page 5
Dept of E&CE
xa1=x*sinc(fs*(ones(length(n),1)*t-nps'*ones(1,length(t))));
figure(1);
subplot(3,1,1);plot(t,xa);
subplot(3,1,2);stem(n,x);
subplot(3,1,3);plot(t,xa1);
Plot:
RYMEC, BLY
Page 6
Dept of E&CE
Page 7
Dept of E&CE
pi=3.141;
tf=0.05;
t=0:0.0005:tf;
fd=input('enter analog frequence:');
xt=cos(2*pi*fd*t);
fs1=1.3*fd;
n1=0:1/fs1:tf;
xn=cos(2*pi*n1*fd);
subplot(3,1,1);
plot(t,xt,'b',n1,xn,'r*-');
title('under sampling plot')
fs2=2*fd;
n2=0:1/fs2:tf;
xn=cos(2*pi*n2*fd);
subplot(3,1,2);
plot(t,xt,'b',n2,xn,'r*-');
title('nyquist plot');
fs3=10*fd;
n3=0:1/fs3:tf;
xn=cos(2*pi*n3*fd);
subplot(3,1,3);
plot(t,xt,'b',n3,xn,'r*-');
title('over sampling plot');
xlabel('time');
ylabel('amplitude');
legend('analog','discrete');
RYMEC, BLY
Page 8
Dept of E&CE
Result:
Enter analog frequency: 100
Plot:
RYMEC, BLY
Page 9
Dept of E&CE
RYMEC, BLY
Page 10
Dept of E&CE
Result:
Enter
Enter
Enter
1
0
the
the
the
-3
1
Plot:
RYMEC, BLY
Page 11
Dept of E&CE
Page 12
Dept of E&CE
disp(y);
n=0:1:lx-1;
subplot(2,2,1)
stem(n,x);
xlabel('n---->');
ylabel('x(n)---->');
title('signal x(n)');
n=0:1:lh-1;
subplot(2,2,2)
stem(n,h);
xlabel('n---->');
ylabel('x(n)---->');
title('signal h(n)');
n=0:1:ly-1;
subplot(2,2,3)
stem(n,y);
xlabel('n---->');
ylabel('x(n)---->');
title('linear convolution');
Result:
Enter the value of x(n)=[1 2 3 4 5]
Enter the value of h(n)=[5 4 3 2 1]
1
2
3
4
5
RYMEC, BLY
Page 13
Dept of E&CE
5
14
26
40
1
55
40
26
14
Plot:
RYMEC, BLY
Page 14
Dept of E&CE
n2=l1+l2-1
y3=cc29(x1,x2,n2)
subplot(3,1,1)
n1=0:1:length(y1)-1;
stem(n1,y1);
xlabel('time------>');
ylabel('amp------>');
title('linear convolution');
y = H' * X1';
subplot(3,1,2)
n2=0:1:length(y2)-1;
stem(n2,y2);
xlabel('time----->');
ylabel('amp----->');
title('circular convolution');
subplot(3,1,3)
n3=0:1:length(y3)-1;
stem(n3,y3);
xlabel('time---->');
ylabel('amp----->');
title('linear conv by circular convolution');
RYMEC, BLY
Page 15
Dept of E&CE
Result:
Enter the first sequence: [1 2 3 4]
Enter the second sequence: [1 2 3 4]
y1 = 1
10
20
25
24
16
n1 = 4
y2 = 26 28 26 20
n2 = 7
y3 = 1 4 10 20 25 24 16
Plot:
RYMEC, BLY
Page 16
Dept of E&CE
Page 17
Dept of E&CE
%property 2:Rxx(n)=Rxx(-n)
l1=length(Rxx)
Zxx=[Rxx(l1:-1:1)]
if(Zxx==Rxx)
disp('Rxx(n) is equal to rxx(-n)');
else
disp('Rxx(n) is not equal to Rxx(-n)');
end
Result:
Enter the sequence:[1 2 3]
Rxx
Enter the sequence[3 2 1]
x1 = 1
rxx = 3
14
centre = 3
n = -2
-1
E = 14
rxx(0) value is equal to the energy of signal
l1 = 5
zxx = 3
14
Plot:
RYMEC, BLY
Page 18
Dept of E&CE
Fig:1
Fig : 2
Page 19
Dept of E&CE
disp('rxy(n) is not equal to rxy(-n)');
end
ex=sum(x.^2)
ey=sum(y.^2)
rxx=xcorr(x,x);
ryy=xcorr(y,y);
c1=ceil(length(rxx)/2)
c2=ceil(length(ryy)/2)
if sqrt(ex*ey)==sqrt(rxx(c1)*ryy(c2))
disp('energy condition is satisfied');
else
disp('energy condition is not satisfied');
end
Result:
Enter the first sequence:[1 2 3]
Enter the second sequence:[2 3 4 5]
rxy =
l1 =
14
26
20
13
ryx = 0
13
20
26
14
14
26
20
13
l= 7
zyx = 5
Page 20
Dept of E&CE
c1 = 3
c2 = 4
Energy condition is satisfied.
Plot:
[r,p,k]=residuez(a,b)
RYMEC, BLY
Page 21
Dept of E&CE
[h,t]=impz(a,b,5)
subplot(2,1,1)
stem(t,h)
xlabel('Time->');
ylabel('Amplitude->');
title('Impulse response h(n)');
n=0:1:length(y)-1;
subplot(2,1,2)
stem(n,y)
xlabel('Time->');
ylabel('Amplitude->');
title('Output Sequence y(n)');
RYMEC, BLY
Page 22
Dept of E&CE
Result:
Enter the Numerator Co-efficient a:[1 3]
Enter the Denominator Co-efficient b:[1 3 2]
r = -1
p = -2 -1
k = []
h =1 0 -2
6 -14
t= 0 1
Plot:
RYMEC, BLY
Page 23
Dept of E&CE
RYMEC, BLY
Page 24
Dept of E&CE
Result:
i/p seq :[1 2 3 4]
x=
1
2
3
4
N=
4
wn = 0.0000 - 1.0000i
n=
0
1
2
3
k=
0
1
2
3
nk =
0
0
0
0
0
1
2
3
0
2
4
6
0
3
6
9
w=
1.0000
1.0000
1.0000
1.0000
1.0000
0.0000 - 1.0000i -1.0000 - 0.0000i -0.0000 + 1.0000i
1.0000
-1.0000 - 0.0000i 1.0000 + 0.0000i -1.0000 - 0.0000i
1.0000
-0.0000 + 1.0000i -1.0000 - 0.0000i 0.0000 - 1.0000i
X=
10.0000
-2.0000 + 2.0000i
-2.0000 - 0.0000i
-2.0000 - 2.0000i
Plot:
RYMEC, BLY
Page 25
Dept of E&CE
Fig: 1
Fig :2
RYMEC, BLY
Page 26
Dept of E&CE
stem(n,angle(x));
title('phase spectrum');
Result:
i/p seq :[10 -2+2i -2 -2-2i]
X =10.0000 -2.0000+2.0000i -2.0000 -2.0000-2.0000i
Enter the length of the sequence: 4
N=4
x =1.0000 2.0000+0.0000i 3.0000-0.0000i 4.0000-0.0000i
RYMEC, BLY
Page 27
Dept of E&CE
Plot:
Fig: 1
Fig: 2
09. Program to find Linear Convolution of two sequences using DFT and
IDFT.
x1=input('enter the 1st sequence x1:');
x2=input('enter 2nd sequence x2:');
RYMEC, BLY
Page 28
Dept of E&CE
l1=length(x1)
l2=length(x2)
n=l1+l2-1;
p=[x1,zeros(1,n-l1)]
q=[x2,zeros(1,n-l2)]
p1=fft(p);
q1=fft(q);
cf=p1.*q1;
s=0:1:n-1
z=ifft(cf,n);
m=z
stem(s,z);
xlabel('time---->');
ylabel('amplitude---->');
title('linear convalution using dft & idft');
RYMEC, BLY
Page 29
Dept of E&CE
Result:
Enter the 1st sequence x1:[1 2 3 4]
Enter 2nd sequence x2:[4 3 2 1]
l1 =
l2 =
p=
q=
s=
m=
Plot:
RYMEC, BLY
Page 30
4.0000
Dept of E&CE
RYMEC, BLY
Page 31
Dept of E&CE
Result:
Enter the 1st sequence x1:[1 2 3 4]
Enter 2nd sequence x2:[4 3 2 1]
l1 = 4
l2 = 4
s=0
m =24
1
22
3
24
30
Plot:
RYMEC, BLY
Page 32
Dept of E&CE
11a). Design a FIR LPF for N=7, W C=1 radians/Sec using hamming
window.
pi=3.142;
wc=(3*pi)/4;
N=7;
t=(N-1)/2;
w=hamming(N);
n=0;
c=sin(wc*(n-t));
d=pi*(n-t);
RYMEC, BLY
Page 33
Dept of E&CE
hd=c/d;
h=hd*w(1);
for n=1:1:N-1
if (n==t)
hd1(n)=wc/pi;
else
a=sin(wc*(n-t));
b=pi*(n-t);
hd1(n)=a/b;
end
h1(n)=hd1(n)*w(n+1);
end
hd=[hd hd1];
h=[h h1];
disp(hd)
disp(w)
disp(h)
wm=0:0.1:pi;
hm=freqz(h,1,wm);
m=20*log10(abs(hm));
plot(wm,m);
xlabel('frequency---->');
ylabel('magnitude---->');
title('response of fir low pass filter');
Result:
0.0751 -0.1591
0.2250
0.7500
0.2250 -0.1591
0.0751
0.0800
0.3100
0.7700
1.0000
0.7700
0.3100
0.0800
0.0060 -0.0493
0.1732
0.7500
0.1732 -0.0493
0.0060
RYMEC, BLY
Page 34
Dept of E&CE
Plot:
11b). Design a FIR HPF for N=7, W C=2 radians/Sec using hamming
window.
pi=3.142;
RYMEC, BLY
Page 35
Dept of E&CE
wc=2;
N=7;
t=(N-1)/2;
w=hamming(N);
n=0;
c=[sin(pi*(n-t))-sin(wc*(n-t))];
d=pi*(n-t);
hd=c/d;
h=hd*w(1);
for n=1:1:N-1
if (n==t)
hd1(n)=1-(wc/pi);
else
a=[sin(pi*(n-t))-sin(wc*(n-t))];
b=pi*(n-t);
hd1(n)=a/b;
end
h1(n)=hd1(n)*w(n+1);
end
hd=[hd hd1];
h=[h h1];
disp(hd)
disp(w)
disp(h)
wm=0:0.1:pi;
hm=freqz(h,1,wm);
m=20*log10(abs(hm));
plot(wm,m);
xlabel('frequency---->');
ylabel('magnitude---->');
title('response of fir high pass filter');
RYMEC, BLY
Page 36
Dept of E&CE
Result:
0.0295
0.0800
0.0024
0.1206 -0.2895
0.3100 0.7700
0.0374 -0.2229
0.3635 -0.2895
1.0000 0.7700
0.3635 -0.2229
Plot:
RYMEC, BLY
Page 37
0.1206
0.3100
0.0374
0.0295
0.0800
0.0024
Dept of E&CE
11c). Design a FIR Band Pass filter for N=7, W C1=1 radians/Sec & WC2=2
radians/Sec using rectangular window.
pi=3.142;
wc1=1;
wc2=2;
N=7;
t=(N-1)/2;
w=boxcar(N);
n=0;
c=[sin(wc2*(n-t))-sin(wc1*(n-t))];
d=pi*(n-t);
hd=c/d;
h=hd*w(1);
for n=1:1:N-1
if (n==t)
hd1(n)=(wc2-wc1)/pi;
else
a=[sin(wc2*(n-t))-sin(wc1*(n-t))];
b=pi*(n-t);
hd1(n)=a/b;
end
h1(n)=hd1(n)*w(n+1);
end
hd=[hd hd1];
h=[h h1];
disp(hd)
disp(w)
disp(h)
RYMEC, BLY
Page 38
Dept of E&CE
wm=0:0.1:pi;
hm=freqz(h,1,wm);
m=20*log10(abs(hm));
plot(wm,m);
xlabel('frequency---->');
ylabel('magnitude---->');
title('response of fir band pass filter');
Result:
-0.0446 -0.2651
1
0.0216
1
-0.0446 -0.2651
0.3183
0.0216
0.3183
Plot:
RYMEC, BLY
Page 39
Dept of E&CE
11d). Design a FIR Band reject filter for N=7, W C1=1 radians/Sec & WC2=2
radians/Sec using rectangular window.
pi=3.142;
wc1=1;
wc2=2;
N=7;
t=(N-1)/2;
w=boxcar(N);
n=0;
c=[sin(wc1*(n-t))-sin(wc2*(n-t))+sin(pi*(n-t))];
d=pi*(n-t);
RYMEC, BLY
Page 40
Dept of E&CE
hd=c/d;
h=hd*w(1);
for n=1:1:N-1
if (n==t)
hd1(n)=(pi-wc2+wc1)/pi;
else
a=[sin(wc1*(n-t))-sin(wc2*(n-t))+sin(pi*(n-t))];
b=pi*(n-t);
hd1(n)=a/b;
end
h1(n)=hd1(n)*w(n+1);
end
hd=[hd hd1];
h=[h h1];
disp(hd)
disp(w)
disp(h)
wm=0:0.1:pi;
hm=freqz(h,1,wm);
m=20*log10(abs(hm));
plot(wm,m);
xlabel('frequency---->');
ylabel('magnitude---->');
title('response of fir band reject filter');
Result:
0.0445
0.2653 -0.0217
0.0445
RYMEC, BLY
0.2653 -0.0217
0.6817 -0.0217
0.2653
0.0445
0.6817 -0.0217
0.2653
0.0445
Page 41
Dept of E&CE
Plot:
Page 42
Dept of E&CE
RYMEC, BLY
Page 43
Dept of E&CE
Result:
enter pass band attenuation:1
ap =
15
0.4712
1.4137
wp =
0.4712
ws =
1.4137
wpp =
0.4802
wss =
1.7082
N=
wc =
0.4802
a=
b=
1.0000
0.2265
0.5271
0.2542
az =
0.0427
0.0854
0.0427
bz =
1.0000 -1.4113
0.6028
Plot:
RYMEC, BLY
Page 44
Dept of E&CE
RYMEC, BLY
Page 45
Dept of E&CE
subplot(3,1,1)
plot(k,abs(h));
subplot(3,1,2)
plot(k,gain);
%grid on;
subplot(3,1,3)
plot(k,angle(h));
Result:
enter the pass band attenuation:3
enter the stop band attenuation:14
enter the pass band frequency:pi/2
enter the stop band frequency :3*pi/4
enter the sampling frequency :1
N=
wn =
1.5828
b=
a=
1.0000
0
4.1360
Num = -0.0000
Den =
6.2758
8.5531 10.3612
0.3293
1.0000 -0.4992
0.4271
6.2758
0.0427
0.3965 -0.1198
0
0.0160
Plot:
RYMEC, BLY
Page 46
Dept of E&CE
RYMEC, BLY
Page 47
Dept of E&CE
PART-B
EXPERIMENTS USING DSP PROCESSOR
Dept of E&CE
int i=0,j;
int x[15]={1,2,3,4,5 };
int h[15]={5,4,3,2,1};
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
for(i=0;i<m+n-1;i++)
printf("%d\n",y[i]);
}
Result:
5 14 26 40 55 40 26 14 5 0 0
Page 49
Dept of E&CE
void main()
{
printf("enter the length of 1st sequence\n");
scanf("%d",&m);
printf("enter the length of 2nd sequence\n");
scanf("%d",&n);
printf("enter the 1st sequence\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("enter the 2nd sequence\n");
for(j=0;j<n;j++)
scanf("%d",&h[j]);
if(m-n!=0)
{
if(m>n)
{
for(i=n;i<m;i++)
h[i]=0;
n=m;
}
else
{
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
}
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++)
a[j]=h[n-j];
for(i=0;i<n;i++)
RYMEC, BLY
Page 50
Dept of E&CE
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
printf("\n circular convolution\n");
for(i=0;i<n;i++)
printf("%d\t",y[i]);
}
Result:
Enter the length of 1st sequence
2
Enter the length of 2nd sequence
4
Enter the 1st sequence
1 2
Enter the 2nd sequence
1234
RYMEC, BLY
Page 51
Dept of E&CE
Circular convolution
9
10
float Y[len]={0,0,0},sum;
void main()
{
int j,k;
float a[order+1]={1,2};
float b[order+1]={1,5,6};
for(j=0;j<len;j++)
{
sum=0;
for(k=1;k<=order;k++)
{
if(j-k>=0)
sum+=b[k]*Y[j-k];
}
if(j<=order)
{
Y[j]=a[j]-sum;
}
else
Y[j]=-sum;
printf("response[%d]%f\n\n",j,Y[j]);
}
}
RYMEC, BLY
Page 52
Dept of E&CE
Result:
response[0]1.000000
response[1]-3.000000
response[2]9.000000
RYMEC, BLY
Page 53
Dept of E&CE
RYMEC, BLY
Page 54
Dept of E&CE
y[2]=y[1];
y[1]=y[0];
x[2]=x[1];
x[1]=x[0];
}
}
Result:
RYMEC, BLY
Page 55
Dept of E&CE
Chose ViewGraphTime/Frequency
RYMEC, BLY
Page 56
Dept of E&CE
PROCEDURE FOR
CODE COMPOSER STUDIO
Procedure:
Start Code Composer
To Start Code Composer Studio, Double Click the 6713 DSK
CCStudio_v3.1 icon on your desktop.
6713 DSK CCStudio v3.1.lnk
RYMEC, BLY
Page 57
Dept of E&CE
Use the Debug Connect menu option to open a debug connection to
the DSK board
Procedure to work on Code Composer Studio
Generation of Linear Convolution
1. To create a New Project
Project New (Lin.pjt)
RYMEC, BLY
Page 58
Dept of E&CE
6. To Compile:
Project Compile File
7. To build or Link:
Project Build,
Which will create the final executable (.out) file.(Eg. Lin.out).
8. Procedure to Load and Run Program:
Load program to DSK:
RYMEC, BLY
Page 59
Dept of E&CE
9. To Execute Project:
Debug Run
RYMEC, BLY
Page 60
Dept of E&CE
RYMEC, BLY
Page 61
Dept of E&CE
Drivers (The CCS CD contains the require drivers for C6713 DSK).
Install the CCS software for C6713 DSK.
DSK Software Installation
You must install the hardware before you install the software on your
system.
The requirements for the operating platform are;
Insert the Installation CD into CD-ROM drive
An install screen appears like below; if not, goes to the windows
Explorer and run setup.exe
RYMEC, BLY
Page 62
Dept of E&CE
If you already have C6000 CC Studio IDE installed on your PC, Do not install DSK
software. CC Studio IDE full tools supports the DSK Plot form
DIAGNOSTIC:
Test the USB port by running DSK port test from the start menu
RYMEC, BLY
Page 63
Dept of E&CE
Use Start Programs Texas Instruments Code Composer Studio Code
Composer Studio C6713 DSK Tools C6713 DSK Diagnostic Utilities
Appendix
RYMEC, BLY
Page 64
Dept of E&CE
1. Input
INPUT prompt for user input. R = INPUT('How many apples') gives the user
the prompt in the text string and then waits for input from the keyboard. The input
can be any MATLAB expression, which is evaluated, using the variables in the
current workspace, and the result
returned in R. If the user presses the return
key without entering anything, INPUT returns an empty matrix. R = INPUT('What is
your name','s') gives the prompt in the text string and waits for character string
input. The typed input is not evaluated; the characters are simply returned as a
MATLAB string.
2. Figure
3. Subplot
RYMEC, BLY
Page 65
Dept of E&CE
SUBPLOT Create axes in tiled positions. H = SUBPLOT(m,n,p), or
SUBPLOT(mnp), breaks the Figure window into an m-by-n matrix of small axes,
selects the p-th axes for the current plot, and returns the axis handle. The axes are
counted along the top row of the Figure window, then the second row, etc. For
example, SUBPLOT(2,1,1), PLOT(income)
SUBPLOT(2,1,2), PLOT(outgo) plots
income on the top half of the window and outgo on the bottom half.
SUBPLOT(m,n,p),
if
the
axis
already
exists,
makes
it
current.
SUBPLOT(m,n,p,'replace'), if the axis already exists, deletes it and creates a new
axis. SUBPLOT(m,n,P), where P is a vector, specifies an axes position that covers all
the subplot positions listed in P. UBPLOT(H), where H is an axis handle, is another
way of making an axis current for subsequent plotting commands.
SUBPLOT('position',[left bottom width height]) creates an axis at the specified
position in normalized coordinates (in the range from 0.0 to 1.0).If a SUBPLOT
specification causes a new axis to overlap an existing axis, the existing axis is
deleted - unless the position of the new and existing axis are identical. For example,
the statement SUBPLOT(1,2,1) deletes all existing axes overlapping the left side of
the Figure window and creates a new axis on that side - unless there is an axes
there with a position that exactly matches the position of the new axes (and 'replace'
was not specified), in which case all other overlapping axes will be deleted and the
matching axes will become the current axes.
SUBPLOT(111) is an exception to the rules above, and is not identical in behavior to
SUBPLOT(1,1,1). For reasons of backwards compatibility, it is a special case of
subplot which does not immediately create an axes, but instead sets up the figure so
that next graphics command executes CLF RESET in the figure (deleting all children
of the figure), and creates a new axes in the default position. This syntax does not
return a handle, so it is an error to specify a return argument. The delayed CLF
RESET is accomplished by setting the figure's NextPlot to 'replace'.
4. plot
blue
green
red
RYMEC, BLY
.
o
x
point
circle
x-mark
Page 66
:
-.
solid
dotted
dashdot
Dept of E&CE
c
m
y
k
cyan
magenta
yellow
black
+
*
s
d
v
^
<
>
p
h
plus
star
square
diamond
triangle (down)
triangle (up)
triangle (left)
triangle (right)
pentagram
hexagram
--
dashed
5. stem
STEM Discrete sequence or "stem" plot. STEM(Y) plots the data sequence Y
as stems from the x axis terminated with circles for the data value. STEM(X,Y) plots
the data sequence Y at the values specified in X. STEM(...,'filled') produces a stem
plot with filled markers. STEM(...,'LINESPEC') uses the linetype specified for the
stems and markers. See PLOT for possibilities. H = STEM(...) returns a vector of line
handles.
6. Exp
7. Ones
ONES
array. ONES(N) is an N-by-N matrix of ones.ONES(M,N) or
ONES([M,N]) is an M-by-N matrix of ones.ONES(M,N,P,...) or ONES([M N P ...]) is an
M-by-N-by-P-by-... array of ones.ONES(SIZE(A)) is the same size as A and all ones.
8. impz
9. disp
DISP Display array. DISP(X) displays the array, without printing the array
name. In all other ways it's the same as leaving the semicolon off an expression
except that empty arrays don't display. If X is a string, the text is displayed.
10. Title
RYMEC, BLY
Page 67
Dept of E&CE
TITLE Graph title. TITLE ('text') adds text at the top of the current axis. TITLE
('text','Property1', PropertyValue1,'Property2',Property Value2,...) sets the values of
the specified properties of the title. H = TITLE (...) returns the handle to the text
object used as the title.
11. length
12. conv
13. xlabel
XLABEL X-axis label. XLABEL('text') adds text beside the X-axis on the
curren
taxis.
XLABEL('text','Property1',PropertyValue1,'Property2',PropertyValue2,...)
sets
the
values of the specified properties of the xlabel. H = XLABEL(...) returns the handle to
the text object used as the label.
14. ylabel
15. max
MAX Largest component. For vectors, MAX(X) is the largest element in X. For
matrices, MAX(X) is a row vector containing the maximum element from each
column. For N-D arrays, MAX(X) operates along the first non-singleton dimension.
[Y,I] = MAX(X) returns the indices of the maximum values in vector I. If the values
along the first non-singleton dimension contain more than one maximal element,
the index of the first one is returned.MAX(X,Y) returns an array the same size as X
and Y with the largest elements taken from X or Y. Either one can be a scalar. [Y,I] =
MAX(X,[],DIM) operates along the dimension DIM. When complex, the magnitude
MAX(ABS(X)) is used, and the angle ANGLE(X) is ignored. NaN's are ignored when
computing the maximum.
16. xcorr
Page 68
Dept of E&CE
sequences: C(m) = E[A(n+m)*conj(B(n))] = E[A(n)*conj(B(n-m))] It is also the
deterministic correlation between two deterministic signals. XCORR(A), when A is a
vector, is the auto-correlation sequence. XCORR(A), when A is an M-by-N matrix, is
a large matrix with 2*M-1 rows whose N^2 columns contain the cross-correlation
sequences for all combinations of the columns of A. The zeroth lag of the output
correlation is in the middle of the sequence, at element or row M.
XCORR(...,MAXLAG) computes the (auto/cross) correlation over the range of lags:
-MAXLAG to MAXLAG, i.e., 2*MAXLAG+1 lags. If missing, default is MAXLAG = M-1.
[C,LAGS] = XCORR(...)
returns a vector of lag indices (LAGS).
XCORR(...,SCALEOPT), normalizes the correlation according to SCALEOPT: 'biased'
- scales the raw cross-correlation by 1/M. 'unbiased' - scales the raw correlation by
1/(M-abs(lags)). 'coeff'
- normalizes the sequence so that the auto-correlations at
zero lag are identically 1.0. 'none'
- no scaling (this is the default).
17. fliplr
18. ceil
CEIL Round towards plus infinity. CEIL(X) rounds the elements of X to the
nearest integers towards infinity.
19. Sum
SUM Sum of elements. For vectors, SUM(X) is the sum of the elements of X. For
matrices, SUM(X) is a row vector with the sum over each column. For N-D arrays,
SUM(X) operates along the first non-singleton dimension. SUM(X,DIM) sums along
the dimension DIM.
Example: If X = [0 1 2
3 4 5]
then sum(X,1) is [3 5 7] and sum(X,2) is [ 3 12];
20. residuez
RYMEC, BLY
Page 69
Dept of E&CE
length(A)+1 If P(j) = ... = P(j+m-1) is a pole of multiplicity m, then the expansion
includes terms of the form
R(j)
R(j+1)
R(j+m-1)
-------------- + ------------------ + ... + -----------------1 - P(j)z^(-1) (1 - P(j)z^(-1))^2
(1 - P(j)z^(-1))^m
[B,A] = RESIDUEZ(R,P,K) converts the partial-fraction expansion back to B/A form.
21. fft
22. ifft
23. hamming
24. fir1
FIR1 FIR filter design using the window method. B = FIR1(N,Wn) designs an
N'th order lowpass FIR digital filter and returns the filter coefficients in length N+1
vector B. The cut-off frequency Wn must be between 0 < Wn < 1.0, with 1.0
corresponding to half the sample rate. The filter B is real and has linear phase. The
normalized gain of the filter at Wn is -6 dB. B = FIR1(N,Wn,'high') designs an N'th
order highpass filter. You can also use B = FIR1(N,Wn,'low') to design a lowpass
filter. If Wn is a two-element vector, Wn = [W1 W2], FIR1 returns an order N
bandpass filter with passband
W1 < W < W2. You can also specify B =
FIR1(N,Wn,'bandpass'). If Wn = [W1 W2], B = FIR1(N,Wn,'stop') will design a
RYMEC, BLY
Page 70
Dept of E&CE
bandstop filter. If Wn is a multi-element vector, Wn = [W1 W2 W3 W4 W5 ... WN],
FIR1 returns an order N multiband filter with bands 0 < W < W1, W1 < W < W2, ...,
WN < W < 1. B = FIR1(N,Wn,'DC-1') makes the first band a passband. B =
FIR1(N,Wn,'DC-0') makes the first band a stopband. B = FIR1(N,Wn,WIN) designs an
N-th order FIR filter using the N+1 length vector WIN to window the impulse
response. If empty or omitted, FIR1 uses a Hamming window of length N+1. For a
complete list of available windows, see the help for the WINDOW function. KAISER
and CHEBWIN can be specified with an optional trailing argument. For example, B
= FIR1(N,Wn,kaiser(N+1,4)) uses a Kaiser window with beta=4. B =
FIR1(N,Wn,'high',chebwin(N+1,R)) uses a Chebyshev window with R decibels of
relative sidelobe attenuation. For filters with a gain other than zero at Fs/2, e.g.,
highpass and bandstop filters, N must be even. Otherwise, N will be incremented
by one. In this case the window length should be specified as N+2.
25. freqz
FREQZ Digital filter frequency response. [H,W] = FREQZ(B,A,N) returns the N-point
complex frequency response vector H and the N-point frequency vector W in
radians/sample of the filter:
jw
-jw
-jmw
jw B(e) b(1) + b(2)e + .... + b(m+1)e
H(e) = ---- = -----------------------------------jw
-jw
-jnw
A(e) a(1) + a(2)e + .... + a(n+1)e
given numerator and denominator coefficients in vectors B and A. The frequency
response is evaluated at N points equally spaced around the upper half of the unit
circle. If N isn't specified, it defaults to 512. [H,W] = FREQZ(B,A,N,'whole') uses N
points around the whole unit circle. H = FREQZ(B,A,W) returns the frequency
response at frequencies designated in vector W, in radians/sample (normally
between 0 and pi). [H,F] = FREQZ(B,A,N,Fs) and [H,F] = FREQZ(B,A,N,'whole',Fs)
return frequency vector F (in Hz), where Fs is the sampling frequency (in Hz). H =
FREQZ(B,A,F,Fs) returns the complex frequency response at the frequencies
designated in vector F (in Hz), where Fs is the sampling frequency (in Hz).
FREQZ(B,A,...) with no output arguments plots the magnitude and unwrapped
phase of the filter in the current figure window.
26. bilinear
Page 71
Dept of E&CE
[Ad,Bd,Cd,Dd] = BILINEAR(A,B,C,D,Fs) is a state-space version. Each of the above
three forms of BILINEAR accepts an optional additional input argument that
specifies prewarping. For example, [Zd,Pd,Kd] = BILINEAR(Z,P,K,Fs,Fp) applies
prewarping before the bilinear transformation so that the frequency responses
before and after mapping match exactly at frequency point Fp (match point Fp is
specified in Hz).
27. buttord
28. butter
29. impinvar
IMPINVAR Impulse invariance method for analog to digital filter conversion. [BZ,AZ]
= IMPINVAR(B,A,Fs) creates a digital filter with numerator and denominator
coefficients BZ and AZ respectively whose impulse response is equal to the impulse
response of the analog filter with coefficients B and A sampled at a frequency of Fs
Hertz. The B and A coefficients will be scaled by 1/Fs.If you don't specify Fs, it
RYMEC, BLY
Page 72
Dept of E&CE
defaults to 1 Hz. [BZ,AZ] = IMPINVAR(B,A,Fs,TOL) uses the tolerance TOL for
grouping repeated poles together. Default value is 0.001, i.e., 0.1%.
30. grid on
GRID Grid lines. GRID ON adds major grid lines to the current axes. GRID
OFF removes major and minor grid lines from the current axes. GRID MINOR
toggles the minor grid lines of the current axes. GRID, by itself, toggles the major
grid lines of the current axes. GRID(AX,...) uses axes AX instead of the current axes.
GRID sets the XGrid, YGrid, and ZGrid properties of the current axes.
set(AX,'XMinorGrid','on') turns on the minor grid.
RYMEC, BLY
Page 73
Dept of E&CE
RYMEC, BLY
Page 74