-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScript_E.m
66 lines (49 loc) · 1.03 KB
/
Script_E.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
f1 = 852;
f2=1477;
fs = 8000;
n = 1600;
t = (0:(n-1))/fs;
f = (-n/2:n/2-1) * (fs/n);
x1 =@(t)sin(2*pi*f1*t);
% subplot(5,3,1);
% plot(t,x1(t));
% title('x1 =sin(2*pi*f1*t)');
% xlabel('Time');
% ylabel('Amplitude');
% sound(x1(t));
x2 = @(t)sin(2*pi*f2*t);
% subplot(5,3,2);
% plot(t,x2(t));
% xlabel('Time');
% ylabel('Amplitude');
% title('x2 =sin(2*pi*f2*t)');
% sound(x2(t));
x =@(t)((sin(2*pi*f1*t)+sin(2*pi*f2*t)));
subplot(5,3,3);
plot(t,x(t));
xlabel('Time');
ylabel('Amplitude');
title('x =(sin(2*pi*f1*t) + sin(2*pi*f2*t))');
sound(x(t));
%Fourier Transform
s1 = abs(fft(x1(t)));
title('Spectrum of x1 ');
xlabel('frequency');
ylabel('Amplitude');
s1shift = fftshift(s1);
subplot(5,3,4);
plot(f,s1shift);
s2 = abs(fft(x2));
title('Spectrum of x2 ');
xlabel('frequency');
ylabel('Amplitude');
s2shift = fftshift(s2);
subplot(5,3,5);
plot(f,s2shift);
s3 = abs(fft(x));
title('Spectrum of x ');
xlabel('frequency');
ylabel('Amplitude');
s3shift = fftshift(s3);
subplot(5,3,6);
plot(f,s3shift);