Академический Документы
Профессиональный Документы
Культура Документы
LAB NO 11
2011-TE-104
15 14 13 12 11 10
9
8
7
6
5
4
Columns 13 through 16
3
2
1
0
3. Assign vector of even samples without assigning it to a variable.
Command:
[0:2:10]
Output:
ans =0
2
4
6
8 10
4. Perform matrix and element wise multiplication of the following.
A=[5 8 6;0 9 4;11 5 3]
B=[6 4 9;7 1 5;2 8 2]
Command:
A=[5 8 6;0 9 4;11 5 3]
A =5
8
6
0
9
4
11
5
3
B=[6 4 9;7 1 5;2 8 2]
B=
6
4
9
7
1
5
2
8
2
i.
Command:
A*B
Output:
ans = 98
1
76
97
LAB NO 11
30 September 2016
2011-TE-104
71 41 53
107 73 130
Command (for element wise):
A.*B
Output:
ans =30 32 54
0
9 20
22 40
6
5. Generate a complex valued matrix A=zeros(1,10) + i*(1,10) And
calculate the absolute square of all elements of the matrix.
Command:
a=zeros(1,10) + i*(1:10)
a=
Columns 1 through 3
0 + 1.0000i
0 + 2.0000i
Columns 4 through 6
0 + 4.0000i
0 + 5.0000i
Columns 7 through 9
0 + 7.0000i
0 + 8.0000i
Column 10
0 +10.0000i
abs (a).^2
0 + 3.0000i
0 + 6.0000i
0 + 9.0000i
Output:
ans =
1
4
9 16 25
6. Function
[y]=cosin wave (t)
36
49
64
81 100
In m flie:
function[y]=cosinewave(t)
f=2;
a=3;
y=a*cos(2*pi*f*t)
plot(t,y,'magenta','linewidth',1.5).
Command:
cosinewave(1:0.1:3)
Output:
y=
Columns 1 through 7
3.0000 0.9271 -2.4271 -2.4271 0.9271 3.0000 0.9271
Columns 8 through 14
-2.4271 -2.4271 0.9271 3.0000 0.9271 -2.4271 -2.4271
Columns 15 through 21
0.9271 3.0000 0.9271 -2.4271 -2.4271 0.9271 3.0000
LAB NO 11
30 September 2016
cos wave
cosine wave
-1
-2
-3
1.2
1.4
1.6
1.8
2
time
2.2
2.4
2.6
2.8
7. Simulink
i.
Y=6u(t) +3u(t)
Block diagram:
6
Step
Gain
3
Scope
Gain1
ii.
Z=cot(t)
Block diagram
Cos Wave
Di vide
Scope
Sine Wave
2011-TE-104
LAB NO 11
30 September 2016
iii.
A=tan(t)
Block diagram
Si ne Wave
Di vide
Scope
Cos Wave
8. Y(t)=0.2x(t)+0.8x(t-2)-0.4x(t-5)
X(t)=3sin(2*pi*f*t)
Simulate the system between t=0 to 10seconds.
Block diagram:
0.2
Si ne Wave
Gai n
0.8
Gai n1
T ransport
Del ay
0.4
Gai n2
T ransport
Del ay1
Scope
2011-TE-104
LAB NO 11
30 September 2016
2011-TE-104
Gain
0.9
Transport
Delay
Gai n1
1
Gai n2
2.5
Gain3
Scope
T ransport
Del ay1
T ransport
Del ay2
1.
a.
b.
c.
d.
e.
Coding
clc;
clear all;
close all;
n=[0:0.1:10];
5
LAB NO 11
30 September 2016
2011-TE-104
fs=500;
f1=2000;
f2=3000;
f3=4500;
subplot(3,1,1);
x1=sin ((f1/fs)*n);
plot (n,x1,'red','linewidth',3)
hold on;
stem (n,x1,'magenta','linewidth',2)
hold of;
subplot (3,1,2);
x2=sin ((f2/fs)*n);
plot (n,x2,'red','linewidth',3)
hold on;
stem (n,x2,'magenta','linewidth',2)
hold of;
subplot (3,1,3);
x3=sin ((f3/fs)*n);
plot (n,x3,'red','linewidth',3)
hold on;
stem (n,x3,'magenta','linewidth',2)
hold of;
1
0
-1
10
10
10
1
0
-1
1
0
-1
As the frequency increases, providing the same sampling rate, the timezperiod of
the signal decreases allowing more cycles to be covered under a certain time
range.
LAB NO 11
30 September 2016
2011-TE-104
clear all;
close all;
f1=2000;
fs=50000;
fd=f1/fs;
n=0:100;
x=sin(fd*n);
subplot(2,1,1)
stem(n,x,'magenta','linewidth',2)
n=1:2:100;
y=sin(fd*n);
subplot(2,1,2)
stem(n,y,'magenta','linewidth',2)
1
0.5
0
-0.5
-1
10
20
30
40
50
60
70
80
90
100
10
20
30
40
50
60
70
80
90
100
1
0.5
0
-0.5
-1
LAB NO 11
30 September 2016
2011-TE-104
fs2=2*(2*fmax);
y2=a*sin((fmax/fs2)*n);
stem(n,y2,'magenta','linewidth',1)
title('Sampling Frequency is Greater than the twice of max frequency i.e
fs=2*(2*fmax)');
subplot(3,1,3);
fs3=2*fmax;
y3=a*sin((fmax/fs3)*n);
stem(n,y3,'magenta','linewidth',1)
title('Sampling Frequency is Equal than the twice of max frequency i.e
fs=2*fmax');
Output
Enter your roll number: 104
Enter max frequency: 100
Sampling Frequency is Half than the twice of max frequency i.e fs=(2*fmax)/2
200
0
-200
10
12
14
16
18
20
Sampling Frequency is Greater than the twice of max frequency i.e fs=2*(2*fmax)
200
0
-200
200
10
12
14
16
18
20
Sampling Frequency is Equal than the twice of max frequency i.e fs=2*fmax
0
-200
10
12
14
16
18
20
clc
close all
clear all
display('Minimum Sampling Frequency(fmin) = Twice of Maximum Frequency i.e
fmin=2*fmax')
fmax=100;
fmin=2*100;
t=[0:0.01:0.5];
x=3*cos(100*pi*t);
plot(t,x,'magenta','linewidth',2)
3
-1
-2
-3
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0.5
1. a) Plot two Continuous Time Signals of 10Hz & 110Hz for 0<t<0.2
sampled at 100 samples/sec.
8
30 September 2016
LAB NO 11
2011-TE-104
clc;
close all;
clear all;
t=[0:0.01:0.2];
x1=cos(2*pi*10*t);
x2=cos(2*pi*110*t);
n=[0:0.01:0.2];
y1=cos((2*pi*(10/100))*n);
y2=cos((2*pi*(110/100))*n);
subplot(3,2,1);
plot(t,x1,'magenta','linewidth',2);
title('f1=10HZ');
subplot(3,2,2);
plot(t,x2,'magenta','linewidth',2);
title('f2=110hz');
subplot(3,2,3);
stem(n,y1,'linewidth',2);
title('f1/fs');
subplot(3,2,4);
stem(n,y2,'linewidth',2);
title('f2/fs');
subplot(3,2,5);
plot(t,x1,'magenta','linewidth',2);
hold on;
stem(n,y1,'linewidth',2);
title('D.T wrt C.T of f1=10HZ');
subplot(3,2,6);
plot(t,x2,'magenta','linewidth',2);
hold on;
stem(n,y2,'linewidth',2);
title('D.T wrt C.T of f2=110HZ');
30 September 2016
LAB NO 11
f1=10HZ
-1
0
0
0.05
0.1
0.15
0.2
f1/fs
0.05
0.1
0.15
0.2
0.15
0.2
f2/fs
0.5
0
0.05
0.1
0.15
0.2
0.05
0.1
0
-1
-1
1
0.5
0
f2=110hz
2011-TE-104
0
0
0.05
0.1
0.15
0.2
-1
0.05
0.1
0.15
0.2
clc
clear all;
close all;
n=0:199;
fd=1/50;
x1=sin(2*pi*fd*n);
q=input('Enter Q Level: ');
xq=(round(x1*q))/q;
xe=xq-x1;
subplot(3,1,1)
plot(n,x1,'magenta','linewidth',2)
title('original signal');
subplot(3,1,2)
plot(n,xq,'magenta','linewidth',2)
title('quantized signal')
subplot(3,1,3)
plot(n,xe,'magenta','linewidth',2)
title('error signal')
10
LAB NO 11
30 September 2016
2011-TE-104
original signal
1
0
-1
20
40
60
80
100
120
140
160
180
200
120
140
160
180
200
120
140
160
180
200
quantized signal
1
0
-1
20
40
60
80
100
error signal
0.5
0
-0.5
20
40
60
80
100
clc
clear all;
close all;
n=0:199;
fd=1/50;
x1=sin(2*pi*fd*n);
q=input('Enter Q Level: ');
xq=(round(x1*q))/q;
subplot(2,1,1)
plot(n,xq,'magenta','linewidth',2)
xe=xq-x1;
subplot(2,1,2)
plot(n,xe,'magenta','linewidth',2)
11
LAB NO 11
30 September 2016
2011-TE-104
px=sum(x1.^2)/(length(x1));
pq=sum(xq.^2)/(length(xq));
SQNR=10*log(px/pq)
Output
Enter Q Level: 2
SQNR =
-1.1333
1
0.5
0
-0.5
-1
20
40
60
80
100
120
140
160
180
200
20
40
60
80
100
120
140
160
180
200
0.4
0.2
0
-0.2
-0.4
clc
clear all;
close all;
n=0:199;
fd=1/50;
x1=sin(2*pi*fd*n);
q1=input('Enter Level of signal 1: ');
q2=input('Enter Level of signal 2: ');
q3=input('Enter Level of signal 3: ');
xq1=(round(x1*q1))/q1;
xq2=(round(x1*q2))/q2;
xq3=(round(x1*q3))/q3;
xe1=xq1-x1;
xe2=xq2-x1;
xe3=xq3-x1;
12
30 September 2016
LAB NO 11
subplot(3,1,1)
plot(n,xe1,'magenta','linewidth',2)
title('Error Signal 1')
subplot(3,1,2)
plot(n,xe2,'magenta','linewidth',2)
title('Error signal 2')
subplot(3,1,3)
plot(n,xe3,'magenta','linewidth',2)
title('Error Signal 3')
px=sum(x1.^2)/(length(x1));
pq1=sum(xq1.^2)/(length(xq1));
pq2=sum(xq2.^2)/(length(xq2));
pq3=sum(xq3.^2)/(length(xq3));
SQNR1=10*log(px/pq1)
SQNR2=10*log(px/pq2)
SQNR3=10*log(px/pq3)
Output
Enter Level of signal 1: 4
Enter Level of signal 2: 14
Enter Level of signal 3: 67
SQNR1 =
-0.1980
SQNR2 =
-0.1700
SQNR3 =
-0.0702
13
2011-TE-104
30 September 2016
LAB NO 11
2011-TE-104
Error Signal 1
0.2
0
-0.2
20
40
60
80
100
120
140
160
180
200
140
160
180
200
140
160
180
200
Error signal 2
0.05
0
-0.05
20
40
60
80
100
120
Error Signal 3
0.01
0
-0.01
14
20
40
60
80
100
120
30 September 2016
LAB NO 11
2011-TE-104
close all;
clear all;
clc;
t=[1:1:100];
num=[1 0];
den=[1 1];
sys=tf(num,den,1);
figure(1)
subplot(3,1,1);
pzmap(sys,'magenta-+');
[mag phase w]=bode(sys);
mag=squeeze(mag);
subplot(3,1,2);
plot(w,mag,'magenta','linewidth',2);
subplot(3,1,3);
impulse(sys,t,'magenta-+');
num1=[1 0];
den1=[1 1.5];
sys1=tf(num1,den1,1);
figure(2)
subplot(3,1,1);
pzmap(sys1,'magenta-+');
[mag phase w]=bode(sys1);
mag=squeeze(mag);
subplot(3,1,2);
plot(w,mag,'magenta','linewidth',2);
subplot(3,1,3);
impulse(sys1,t,'magenta-+');
num2=[2 5 12];
den2=[1 2 10];
15
30 September 2016
LAB NO 11
2011-TE-104
Imaginary Ax is
sys2=tf(num2,den2,1);
figure(3)
subplot(3,1,1);
pzmap(sys2,'magenta-+');
[mag phase w]=bode(sys2);
mag=squeeze(mag);
subplot(3,1,2);
plot(w,mag,'magenta','linewidth',2);
subplot(3,1,3);
impulse(sys2,t,'magenta-+');
Figure 1
Pole-Zero Map
1
0
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
Real Axis
15
x 10
Amplitude
0.5
1.5
2.5
3.5
Impulse Response
1
0
-1
10
20
30
40
50
60
70
80
90
100
Time (sec)
Figure 2
16
LAB NO 11
Im a g in a r y A x is
30 September 2016
2011-TE-104
Pole-Zero Map
1
0
-1
-1.5
-1
-0.5
0.5
Real Axis
2
1
0
0.5
1.5
A m p litu d e
17
2.5
3.5
Impulse Response
x 10
0
-5
10
20
30
40
50
60
70
80
90
100
Time (sec)
Imaginary Axis
Figure 3:
Pole-Zero Map
5
0
-5
-1.5
-1
-0.5
0.5
Real Axis
1.5
1
0.5
0.5
1.5
50
Amplitude
2.5
3.5
Impulse Response
x 10
0
-1
10
20
30
40
50
60
70
80
90
100
Time (sec)
17
LAB NO 11
30 September 2016
2011-TE-104
2. Refer to q1 & show that system is Margi nary stable. Also plot
bode magnitude & impulse response
Coding
clc;
close all;
clear all;
num=poly([j -j]);
den=poly([exp(0) exp(-0.2)]);
sys=tf(num,den,1);
subplot(3,1,1)
pzmap(sys, 'magenta')
xlim([-2 2])
ylim([-4 4])
[mag phase w]=bode(sys)
mag=squeeze(mag)
subplot(3,1,2)
plot(w,mag,'magenta','linewidth',2)
xlim([0 pi])
subplot(3,1,3)
impulse(sys,'magenta')
Pole-Zero Map
Imaginary Axis
0
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
Real Axis
1500
1000
500
0
0.5
2.5
Impulse Response
20
Amplitude
1.5
10
0
10
15
20
25
30
35
Time (sec)
30 September 2016
LAB NO 11
2011-TE-104
2.Use fft command to compute DFT function for the given data
sequence in Task#1.Also plot the phase and magnitude graphs of
DFT functions
Coding
clc;
close all;
clear all;
x=[1 2 1 0];
n=[0:1:3];
y=ft(x)
mag=abs(y)
subplot(3,1,1)
stem(n,mag,'magenta','linewidth',2);
title('magnitude graph');
Xlabel('n')
Ylabel('magnitude')
b=imag(y);
subplot(3,1,2)
stem(n,b,'magenta','linewidth',2);
title('imaginary');
Xlabel('n')
Ylabel('imaginary axix')
19
30 September 2016
2011-TE-104
c=angle(y);
subplot(3,1,3)
stem(n,c,'magenta','linewidth',2);
title('phase graph')
Xlabel('n')
i m a g i n a r y amx ai xg n i t u d e
Ylabel('phase')
phase
LAB NO 11
magnitude graph
4
2
0
0.5
1.5
n
imaginary
2.5
0.5
1.5
n
phase graph
2.5
0.5
1.5
n
2.5
2
0
-2
2
0
-2
y =Columns 1 through 3
4.0000
0 - 2.0000i
Column 4
0 + 2.0000i
mag =
4
2
0
2
clc;
close all;
clear all;
[y,fs,bits]= wavread('dsp1.wav');
ts=1/fs;
n=[0:length(y)-1];
t=n*ts;
k=n;
df=fs/length(y);
f=df*k;
a=ft(y);
magy=abs(y);
sound(y,fs);
subplot(2,1,1)
plot(f,magy,'magenta','linewidth',2);
20
LAB NO 11
30 September 2016
2011-TE-104
grid on;
xlim([0 fs/2]);
subplot(2,1,2);
plot(f,magy,'magenta','linewidth',2);
grid on;
xlim([0 1000]);
1
0.5
0.5
1.5
2
4
x 10
0.2
0.15
0.1
0.05
0
100
200
300
400
500
600
700
800
for col=1:200;
a(row,col)=1;
end
end
for row=1:20:200;
for col=1:200;
a(row,col)=0;
end
end
21
900
1000
30 September 2016
LAB NO 11
imshow(a)
for row=1:200;
for col=1:200;
a(row,col)=1;
end
end
for row=1:20:200;
for col=1:200;
a(row,col)=0;
end
end
figure(1);
imshow(a);
title('Original Image');
J=flipud(a);
figure(2)
imshow(J)
title('Flipped Image');
I=imread('Task1.tif');
K=255-I;
figure(3)
imshow(K)
title('Negative Image');
22
2011-TE-104
LAB NO 11
30 September 2016
Original Image
2011-TE-104
Flipped Image
3. Take any image and add speckle , poisson and then pass
through average and midian filter.
Coding
23
clc;
close all;
clear all;
I=imread('pout.tif');
figure(1);
imshow(I);
title('Original Image');
k=imnoise(I,'speckle',0.10);
l=imnoise(k,'poisson');
figure(2);
imshow(l);
title('Poisson & Speckle added');
a=filter2(fspecial('average',3),l)/255;
b=medfilt2(a,[3 3]);
figure(3);
imshow(b);
title('Average & median filter')
30 September 2016
LAB NO 11
Original Image
2011-TE-104
4. Import any image and display it. Also convert image format
into
a. Grayscale image
b. Indexed image
c. Binary image
d. Use subplot command to display results.
Coding:
clc;
close all;
clear all
I=imread('Tulips','JPEG');
subplot(2,2,1)
imshow(I);
title('Original Image');
J=rgb2gray(I);
subplot(2,2,2)
24
LAB NO 11
30 September 2016
2011-TE-104
imshow(J)
title('Grayscale Image');
[IND,map]=rgb2ind(I,32);
subplot(2,2,3)
imagesc(IND);
title('Indexed Image');
K=im2bw(I);
subplot(2,2,4)
imshow(K);
title('binary Image');
Original Image
Grayscale Image
Indexed Image
binary Image
200
400
600
200
25
400
600
800 1000
30 September 2016
LAB NO 11
2011-TE-104
#include <stdio.h>
#define LED_OFF 0*07000000
#define msec 500
void main(void)
{
short toggle=0;
int LED[]={0*06000000 , 0*05000000 , 0*03000000}
printf("The LED Dancing Program");
LED_control(LED_OFF);
while(toggle==0)
{
for(int a=0;a<3;a++)
{
LED_control(LED[0]);
delay_msec(msec);
}
for(a=0;a<2;a++)
{
LED_control(LED[1]);
delay_msec(msec);
}
LED_control(LED[2]);
delay_msec(msec);
toggle=1;
}
while(toggle==1)
{
LED_control(LED[0]);
delay_msec(msec);
for(int a=0;a<2;a++)
{
LED_control(LED[1]);
delay_msec(msec);
}
for(a=0;a<3;a++)
{
LED_control(LED[2]);
delay_msec(msec);
}
toggle=0;
26
30 September 2016
LAB NO 11
2011-TE-104
27
30 September 2016
LAB NO 11
2011-TE-104
TI TMS320C6711
DIFFERENCE EQUATION:
Y[n] = x[n] + ax [n-D]
Where,
28
30 September 2016
LAB NO 11
2011-TE-104
a = Gain,
D =Delay.
It follows the following block diagram
Edit
Edit
Compile
Assemb
le
Link
STEPS:=
i.
ii.
iii.
Then click on sample time , single task rate transition and press none.
iv.
Real time workshop , chose Ti-c6000.tlc file open browse and click tic6000.tlc
v.
vi.
Click on c6000 target selection, system target file and chose C6711 DSK.
vii.
30 September 2016
viii.
LAB NO 11
2011-TE-104
ix.
Again open configure parameter , real time , click on build and press ok.
x.
QUICK TEST OF DSK
Launch CCS from the icon on the desktop. Press GEL Check DSK Quick Test.
The Quick Test can be used for confirmation of correct operation and installation.
The following message is then displayed:
Switches: 7
Revision: 2
Target is OK
This assumes that the first three switches, USER_SW1, USER_SW2, and
USER_SW3, are all in the
up (ON) position. This assumes that the first three switches, USER_SW1,
USER_SW2, and USER_SW3,are all in the up (ON) position. Change the switches
to (1 1 0 x)2 so that
the first two switches are up (press the third switch down). The fourth switch is
not
used. Repeat the procedure to select GEL Check DSK Quick Test and verify
that the value of the switches is now 3 (with the display Switches: 3).You can
set the value of the
first three user switches from 0 to 7.Within your program you can then direct the
execution of your
code based on these eight values. Note that the Quick
Test cycles the LEDs three times
Conclusion
If you have followed the above steps correctly it will show you the message that
Build procedure complete and if you have missed any configuration step it will
generate code. As a result you will listen an echo until the time out.
30
30 September 2016
31
LAB NO 11
2011-TE-104