Professional Documents
Culture Documents
-2107109
EXPERIMENT NO.- 2
AIM :- WAP to plot sine, cosine and tangent waveforms
Software Used : - MATLAB 6.5
PROGRAM
t=0:1.0:100
f=50
%sine wave plot
x=sin(2*3.14*f*t)
subplot(2,2,1)
plot(z)
grid
title('Sinusoidal Wave')
xlabel('Time---->')
ylabel('Amp---->')
%cosine wave plot
y=cos(2*3.14*f*t)
subplot(2,2,2)
plot(k)
grid
title('Cosine Wave')
xlabel('Time---->')
ylabel('Amp---->')
%tangent wave plot
t=0:0.5:100
z=tan(2*3.14*f*t)
subplot(2,2,3)
plot(b)
grid
title('Tangent Wave')
xlabel('Time---->')
ylabel('Amp---->')
OUTPUT WAVEFORM
Command Window
>>
t=
Columns 1 through 23
0
19
2 3
21 22
20
10
11
12
13
14
15
16
17
28
29
30
31
32
33
34
35
36
37
38
39
52
53
54
55
56
57
58
59
60
61
62
Columns 24 through 46
23
24
40
25
41
26
42
27
43
44
45
Columns 47 through 69
46
47
63
64
48
65
49
66
50
67
51
68
f=
50
x=
Columns 1 through 14
0 -0.1586 -0.3132 -0.4598 -0.5948 -0.7148 -0.8167 -0.8978 -0.9563
-0.9906 -0.9998 -0.9836 -0.9426 -0.8777
Columns 15 through 28
-0.7907 -0.6835 -0.5591 -0.4206 -0.2714 -0.1153
0.4982 0.6294 0.7447 0.8411 0.9162
0.0437
0.2016
0.3544
Columns 29 through 42
0.9682 0.9956 0.9979 0.9748 0.9271
0.3805 0.2291 0.0718 -0.0873 -0.2442
y=
0.8560
0.7631
0.6510
0.5224
18
Columns 1 through 14
1.0000 0.9873 0.9497 0.8880 0.8038
0.1370 -0.0219 -0.1801 -0.3339 -0.4791
0.6993
0.5771
0.4403
0.2923
Columns 15 through 28
-0.6123 -0.7299 -0.8291 -0.9073 -0.9625 -0.9933 -0.9990 -0.9795 -0.9351
-0.8671 -0.7771 -0.6674 -0.5409 -0.4006
Columns 29 through 42
-0.2503 -0.0936 0.0655 0.2229 0.3747
0.9248 0.9734 0.9974 0.9962 0.9697
0.5170
0.6462
0.7591
0.8527
t=
Columns 1 through 14
0
4.5000
0.5000
5.0000
1.0000
5.5000
1.5000
6.0000
2.0000
6.5000
2.5000
3.0000
3.5000
4.0000
Columns 15 through 28
7.0000 7.5000 8.0000 8.5000 9.0000 9.5000 10.0000 10.5000 11.0000
11.5000 12.0000 12.5000 13.0000 13.5000
Columns 29 through 42
14.0000 14.5000 15.0000 15.5000 16.0000 16.5000 17.0000 17.5000
18.0000 18.5000 19.0000 19.5000 20.0000 20.5000
b=
Columns 1 through 14
0 -0.0798 -0.1606 -0.2435 -0.3298 -0.4206 -0.5178 -0.6234 -0.7400
-0.8712 -1.0221 -1.1998 -1.4150 -1.6851
Columns 15 through 28
-2.0391 -2.5308 -3.2712 -4.5349 -7.2317 -17.2891 45.7441
3.7477 2.8235 2.2392 1.8320 1.5287
Columns 29 through 42
9.8193
5.4606
0.5642
0.4636
0.3701
0.2820
Roll No.-2106052
Program No.-2
%WAP to plot the following functions 1.impulse 2.unit step 3.unit ramp 4.exponential
5.sinusoidal
%1.impulse function
N=10
F=-10:10
x=[zeros(1,N) ones(1,1) zeros(1,N)]
subplot(2,3,1)
stem(F,x)
title('Impulse Function')
xlabel('Time---->')
ylabel('Amplitude---->')
%2.unit step function
N=10
F=-10:10
x=[zeros(1,N) ones(1,1) ones(1,N)]
subplot(2,3,2)
stem(F,x)
title('Unit step function')
xlabel('Time---->')
ylabel('Amplitude---->')
%3.unit ramp function
N=10
F=0:10
x=F
subplot(2,3,3)
stem(F,x)
title('Unit Ramp Function')
xlabel('Time---->')
ylabel('Amplitude---->')
%4.exponential function
N=10
F=-10:10
x=exp(F)
subplot(2,3,4)
stem(F,x)
title('Exponential function')
xlabel('Time---->')
ylabel('Amplitude---->)
%5.sinusoidal function
N=50
F=0:1.0:100
x=sin(2*3.14*N*F)
subplot(2,3,5)
stem(F,x)
title(Sine Function)
xlabel(Time---->)
ylabel(Amplitude---->)
Output Waveform
Command Window
>>
N=
10
F=
Columns 1 through 17
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
Columns 18 through 21
7
10
x=
Columns 1 through 17
0
Columns 18 through 21
0
N=
10
F=
Columns 1 through 17
-10
-9
-8
-7
-6
Columns 18 through 21
7
10
x=
Columns 1 through 17
-5
-4
-3
-2
-1
Columns 18 through 21
1
10
10
N=
10
F=
0
x=
0
N=
10
F=
Columns 1 through 17
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
Columns 18 through 21
7
10
x=
1.0e+004 *
Columns 1 through 10
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0020
0.0055
0.0148
0.0403
0.1097
0.2981
Columns 11 through 20
0.0001
0.8103
0.0003
Column 21
0.0007
2.2026
N=
50
F=
Columns 1 through 17
0
10
11
12
13
14
15
16
22
23
24
25
26
27
28
29
30
31
32
33
39
40
41
42
43
44
45
46
47
48
49
50
Columns 18 through 34
17
18
19
20
21
Columns 35 through 51
34
35
36
37
38
x=
Columns 1 through 10
0 -0.1586 -0.3132 -0.4598 -0.5948 -0.7148 -0.8167 -0.8978 -0.9563
-0.9906
Columns 11 through 20
-0.9998 -0.9836 -0.9426 -0.8777 -0.7907 -0.6835 -0.5591 -0.4206 -0.2714
-0.1153
Columns 21 through 30
0.0437
0.9956
0.2016
0.3544
0.4982
0.6294
0.7447
0.8411
0.9162
0.9682
0.8560
0.7631
0.6510
0.5224
0.3805
0.2291
Columns 31 through 40
0.9979
0.0718
0.9748
0.9271
Columns 41 through 50
-0.0873 -0.2442 -0.3949 -0.5356 -0.6628 -0.7731 -0.8639 -0.9329 -0.9782
-0.9988
>>
2106025
Date-
Roll No.-2106052
Program No.-3
%WAP to calculate DTFT of 5 point signal and plot real part ,imaginary part,magnitude
and phase of fuction
x=[1,2,3,4,5]
n=0:4
k=0:4
y=x*(exp(-j*2*3.14/5)).^(k'*n)
subplot(2,3,1)
stem(n,y)
title('DTFT Plot')
xlabel('n---->')
ylabel('DTFT--->')
%Magnitude plot
m=abs(y)
subplot(2,3,2)
stem(n,m)
xlabel('n----->')
ylabel('magnitude--->')
title('Magnitude Plot')
%Phase plot
p=angle(y)
subplot(2,3,3)
stem(n,p)
xlabel('n----->')
ylabel('Phase---->')
title('Phase Plot')
%Real plot
r=real(y)
subplot(2,3,4)
stem(n,r)
xlabel('n----->')
ylabel('real part--->')
title('Real Plot')
%Imaginary plot
i=imag(y)
subplot(2,3,5)
stem(n,i)
xlabel('n----->')
ylabel('imaginary part--->')
title('Imaginary Plot')
Output waveform
Command Window
>>
x=
1
n=
0
k=
0
y=
15.0000
3.4605i
m=
15.0000
4.2570
2.6298
2.6270
4.2384
p=
0
2.2023
r=
15.0000 -2.5131 -2.5062 -2.4906 -2.4473
i=
0
3.4360
>>
Date-
Roll No.-2106052
Program No.-4
%WAP to obtain DTFT of a 21 point triangular pulse over the domain -10<n<10
n=-10:10
x=tripuls(n,21)
k=-10:10
N=21
%DTFT plot
y=x*(exp(-j*2*3.14/21)).^(k'*n)
subplot(2,3,1)
stem(n,y)
xlabel('n---->')
ylabel('DTFT--->')
title('DTFT Plot')
%Magnitude plot
m=abs(y)
subplot(2,3,2)
stem(n,m)
xlabel('n----->')
ylabel('magnitude--->')
title('Magnitude Plot')
%Phase plot
p=angle(y)
subplot(2,3,3)
stem(n,p)
xlabel('n----->')
ylabel('Phase---->')
title('Phase Plot')
%Real plot
r=real(y)
subplot(2,3,4)
stem(n,r)
xlabel('n----->')
ylabel('real part--->')
title('Real Plot')
%Imaginary plot
i=imag(y)
subplot(2,3,5)
stem(n,i)
xlabel('n----->')
ylabel('imaginary part--->')
title('Imaginary Plot')
Output Waveform
Command Window
>>
n=
-10 -9
9 10
-8
-7
-6
-5
-4
-3
-2
-1
x=
Columns 1 through 14
0.0476 0.1429 0.2381 0.3333 0.4286
0.9048 1.0000 0.9048 0.8095 0.7143
0.5238
0.6190
0.7143
0.8095
Columns 15 through 21
0.6190
0.5238
0.4286
0.3333
0.2381
0.1429
0.0476
-8
-6
-4
-2
k=
-10 -9
10
-7
-5
-3
-1
N=
21
y=
Columns 1 through 8
0.0443
0.0613 - 0.0000i 0.0349 + 0.0000i 0.0953 + 0.0000i 0.0293 +
0.0000i 0.1786 - 0.0000i 0.0261 + 0.0000i 0.4813 + 0.0000i
Columns 9 through 16
0.0244 - 0.0000i 4.2678 + 0.0000i 10.5238
4.2678 - 0.0000i 0.0244 +
0.0000i 0.4813 + 0.0000i 0.0261 - 0.0000i 0.1786 - 0.0000i
Columns 17 through 21
0.0293 + 0.0000i 0.0953 + 0.0000i 0.0349 + 0.0000i 0.0613 - 0.0000i 0.0443 +
0.0000i
m=
Columns 1 through 14
0.0443 0.0613 0.0349 0.0953 0.0293
4.2678 10.5238 4.2678 0.0244 0.4813
0.1786
0.0261
0.0613
0.0443
0.4813
0.0244
Columns 15 through 21
0.0261
0.1786
0.0293
0.0953
0.0349
p=
1.0e-013 *
Columns 1 through 14
0 -0.0374 0.0318 0.0211 0.0260 -0.0132
0.0005
0 -0.0011 0.0755 0.0040
0.0306
0.0040 -0.1211
Columns 15 through 21
-0.0080 -0.0159
0.0852
0.0080
0.0318 -0.0453
0.0125
r=
Columns 1 through 14
0.0443 0.0613 0.0349 0.0953 0.0293
4.2678 10.5238 4.2678 0.0244 0.4813
0.1786
0.0261
0.0613
0.0443
0.4813
0.0244
Columns 15 through 21
0.0261
0.1786
0.0293
0.0953
0.0349
i=
1.0e-015 *
Columns 1 through 14
0 -0.2290 0.1110 0.2012 0.0763 -0.2359
0.2229
0 -0.4727 0.1839 0.1943
Columns 15 through 21
0.0798
0.1908 -0.2949
-0.0208 -0.2845
>>
Date-
0.2498
0.0763
0.1110 -0.2776
0.0555
Roll No.-2106052
Program No.-5
%WAP to study different window functions available in single processing toolbox and
their controlling parameters
n=65
beta=20
%Rectangular window
w1=window(@rectwin,n)
subplot(3,2,1)
plot(w1)
title('Rectangular window')
%Hamming window
w2=window(@hamming,n)
subplot(3,2,2)
plot(w2)
title('Hamming window')
%Hanning window
w3=window(@hanning,n)
subplot(3,2,3)
plot(w3)
title('Hanning window')
%Bartlett window
w4=window(@bartlett,n)
subplot(3,2,4)
plot(w4)
title('Bartlett window')
%Blackman window
w5=window(@blackman,n)
subplot(3,2,5)
plot(w5)
title('Blackman window')
%Kaiser window
w6=window(@kaiser,n,beta)
subplot(3,2,6)
plot(w6)
title('Kaiser window')
Output Waveform
Date-
Roll No.-2106052
Program No.-6
%wap to calculate convolution and multiplication of two signals
x=0:.5:10
%First input signal
y=(.7).^x
subplot(2,2,1)
stem(y)
title('y')
%Second input signal
z=(.9).^x
subplot(2,2,2)
stem(z)
title('z')
%convolution
c=convn(y,z)
subplot(2,2,3)
stem(c)
title('convolution')
%multiplication
m=y.*z
subplot(2,2,4)
stem(m)
title('multiplication')
Command Window
>>
x=
Columns 1 through 5
0
0.5000
1.0000
1.5000
2.0000
Columns 6 through 10
2.5000
3.0000
3.5000
4.0000
4.5000
6.5000
7.0000
9.0000
9.5000
0.5857
0.4900
0.2401
0.2009
0.0984
0.0824
Columns 11 through 15
5.0000
5.5000
6.0000
Columns 16 through 20
7.5000
8.0000
8.5000
Column 21
10.0000
y=
Columns 1 through 5
1.0000
0.8367
0.7000
Columns 6 through 10
0.4100
0.3430
0.2870
Columns 11 through 15
0.1681
0.1406
0.1176
Columns 16 through 20
0.0689
0.0576
0.0482
0.0404
0.0338
0.8538
0.8100
0.6561
0.6224
0.5042
0.4783
0.3874
0.3675
2.8565
3.2000
3.7630
3.7708
3.5345
3.4354
Column 21
0.0282
z=
Columns 1 through 5
1.0000
0.9487
0.9000
Columns 6 through 10
0.7684
0.7290
0.6916
Columns 11 through 15
0.5905
0.5602
0.5314
Columns 16 through 20
0.4538
0.4305
0.4084
Column 21
0.3487
c=
Columns 1 through 5
1.0000
1.7853
2.3937
Columns 6 through 10
3.4457
3.6119
3.7135
Columns 11 through 15
3.7454
3.6938
3.6219
Columns 16 through 20
3.3281
3.2149
3.0982
2.9795
2.8604
1.5492
1.2760
0.5706
0.4619
0.1843
0.1423
0.0374
0.0222
Columns 21 through 25
2.7419
2.2704
1.8771
Columns 26 through 30
1.0484
0.8590
0.7015
Columns 31 through 35
0.3717
0.2970
0.2353
Columns 36 through 40
0.1077
0.0794
0.0563
Column 41
0.0098
m=
Columns 1 through 5
1.0000
0.7937
0.6300
0.5000
0.3969
0.1575
0.1250
0.0496
0.0394
0.0156
0.0124
Columns 6 through 10
0.3150
0.2500
0.1985
Columns 11 through 15
0.0992
0.0788
0.0625
Columns 16 through 20
0.0313
0.0248
Column 21
0.0098
>>
0.0197
Output waveform
Date-
Roll No.-2106052
Program No.-1
Aim:-Write a program to plot following waveforms: Sinusoidal wave, Cosine wave,
Tangent wave.
Date-
Roll No.-2106052
Program No.-2
Aim:-Write a program to plot the following function waveforms: Impulse function, Unit
step function, Ramp function, Sinusoidal function, Exponential function.
Date-
Roll No.-2106052
Program No.-3
Aim:-Write a program to calculate the DTFT of a 5 point signal and plot the real part,
imaginary part , magnitude n phase of function.
Date-
Roll No.-2106052
Program No.-4
Aim:-Write a program to obtain the DTFT of a 21 point triangular pulse over the
domain -10<n<10.
Date-
Roll No.-2106052
Program No.-5
Aim:-Write a program to study different window functions available in single
processing toolbox and their controlling parameters.
Date-
Roll No.-2106052
Program No.-6
Aim:-Write a program to calculate convolution and multiplication of 2 signals.