-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexperiment_2.m
More file actions
84 lines (84 loc) · 1.38 KB
/
experiment_2.m
File metadata and controls
84 lines (84 loc) · 1.38 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
%% Experiment 2
%% 1. (a)
clc;clear;
f0 = 25; fs = 400;
n = -10:1/fs:10;
x1 = 5.3*cos(2*pi*f0/fs*n+pi/4);
x2 = 4*cos(2*pi*f0/fs*n);
subplot(221);
plot(n,x1);
legend('X1');
subplot(223);
plot(n,x2);
legend('X2');
subplot(222);
plot(n,x1.*x2);
legend('X1.X2');
subplot(224);
plot(n,x1+x2);
legend('X1+X2');
%% 1. (b)
clc;clear;
t = -100:0.01:100;
x1 = exp(-0.1*t).*sin(0.6*t);
x2 = t>=0;
subplot(221);
plot(t,x1);
legend('X1');
subplot(223);
plot(t,x2);
legend('X2');
subplot(222);
plot(t,x1.*x2);
legend('X1.X2');
subplot(224);
plot(t,x1+x2);
legend('X1+X2');
%% 2. (a)
clc;clear;
f = 0.5;
t = 0:0.01:5;
x = exp(-2*t).*cos(2*pi*f*t+pi/3);
t1 = 2*t-6;
y = exp(-2*t).*cos(2*pi*f*t1+pi/3);
figure;
plot(t,x, t,y);
legend('X(t)','X(2t-6)');
grid on;
%% 2. (b)
clc;clear;
s = 10;
n = -10:0.01:10;
x = cos(2*pi*n/s);
n1 = 2*n-6;
y = cos(2*pi*n1/s);
figure;
plot(n,x, n,y);
legend('X[n]','X[2n-6]');
grid on;
%% 3. (a)
clc;clear;
n = -3:0.01:3;
a = [2 1/2 1/4];
n1 = a(:)*n;
b = 0.3;
x = 2*exp(b*n);
x1 = 2*exp(b*n1(1,:));
x2 = 2*exp(b*n1(2,:));
x3 = 2*exp(b*n1(3,:));
figure;
plot(n,x, n,x1, n,x2, n,x3);
legend('X[n]','X[2n]','X[1/2*n]','X[1/4*n]');
%% 3. (b)
clc;clear;
n = -1:0.01:1;
a = [2 1/2 1/4];
n1 = a(:)*n;
x = 2*cos(2*pi*n);
x1 = 2*cos(2*pi*n1(1,:));
x2 = 2*cos(2*pi*n1(2,:));
x3 = 2*cos(2*pi*n1(3,:));
figure;
plot(n,x, n,x1, n,x2, n,x3);
grid on;
legend('X[n]','X[2*n]','X[1/2*n]','X[1/4*n]');