Lab_01_Signal
Lab_01_Signal
>> f = 4000
T = 1/f
st = T/25
tt = -T:st:T
1
b
A1 = 21; % My age
A2 = 1.2 * A1; % Given scaling factor
f = 4000; % Frequency in Hz
T = 1 / f; % Period
D = 17; % Day of birth
M = 9; % Month of birth
%% Compute time shifts
tm1 = (37.2 / M) * T;
tm2 = (-41.3 / D) * T;
%% Generate signals
x1t = A1 * cos(2 * pi * f * (t - tm1));
x2t = A2 * cos(2 * pi * f * (t - tm2));
%% Plot in subplots
figure;
subplot(3,1,1);
plot(t, x1t, ’b-’), grid on;
title(’Signal x_1(t)- Vu & Minh’);
xlabel(’Time (sec)’);
ylabel(’Amplitude’);
subplot(3,1,2);
plot(t, x2t, ’r--’), grid on;
title(’Signal x_2(t) - Vu & Minh’);
xlabel(’Time (sec)’);
ylabel(’Amplitude’);
2
c
x3t = x1t + x2t;
% Plot x1(t)
subplot(3,1,1);
plot(t, x1t, ’b-’), grid on;
title(’Signal x_1(t) - Vu & Minh’);
xlabel(’Time (sec)’);
ylabel(’Amplitude’);
% Plot x2(t)
subplot(3,1,2);
plot(t, x2t, ’r--’), grid on;
title(’Signal x_2(t) - Vu & Minh’);
xlabel(’Time (sec)’);
ylabel(’Amplitude’);
3
d
Ts = 0.5e-3; % Sampling interval = 0.5 ms = 0.0005 sec
fs = 1 / Ts;
t_sampled = -T:Ts:T;
x3_sampled = A1 * cos(2 * pi * f * (t_sampled - tm1)) +
A2 * cos(2 * pi * f * (t_sampled - tm2));
4
e
% Compute statistics
max_x3 = max(x3t);
min_x3 = min(x3t);
mean_x3 = mean(x3t);
std_x3 = std(x3t);
%% Display results
fprintf(’Statistics of x3(t):\n’);
fprintf(’Maximum Value: %.4f\n’, max_x3);
fprintf(’Minimum Value: %.4f\n’, min_x3);
fprintf(’Mean Value: %.4f\n’, mean_x3);
fprintf(’Standard Deviation: %.4f\n’, std_x3);
5
2 Theoretical Calcualtions
a
From the previous task, we got the result:
37.2 37.2 1
tm1 = ×T = × = 0.001033s
M 9 4000
−41.3 −41.3 1
tm2 = ×T = × = −0.000607s
D 17 4000
The phase of a signal xi (t) can be calculated by ϕ = 2πf tmi Therefore, by substituting tm1 and
tm2 into that equation, we found ϕ1 ≈ 8.267π; ϕ2 ≈ −4.859π, because ϕ is normally presented in range
[0, 2π] we can convert to ϕ1 ≈ 0.267π; ϕ2 ≈ 1.141π
Note that : ϕi here is in the formula xi (t) = Ai cos(2πf t − ϕi ) to avoid ambiguity in sign
of ϕ value
b
As we measured from the plot, the time-delay is t3 = 0.000105s, therefore the initial phase is ϕ3 =
2πf t3 = 2.6389π which has the similar meaning with ϕ3 = 0.6389π. Besides that, the amplitude of
6
x3 (t) is A3 ≈ 9.94
c
Consider two sinusoidal signals of the same angular frequency ω:
x1 (t) = A1 cos(ωt + ϕ1 )
x2 (t) = A2 cos(ωt + ϕ2 )
Using phasor representation, we express them as complex exponential:
X1 = A1 ejϕ1 , X2 = A2 ejϕ2
The total signal is:
X3 = X1 + X2 = A1 ejϕ1 + A2 ejϕ2
The resultant phasor X3 has magnitude and phase given by:
p
A3 = |X3 | = (A1 cos ϕ1 + A2 cos ϕ2 )2 + (A1 sin ϕ1 + A2 sin ϕ2 )2
−1 A1 sin ϕ1 + A2 sin ϕ2
ϕ3 = tan
A1 cos ϕ1 + A2 cos ϕ2
Substitute aforementioned values of A1 , A2 , ϕ1 , ϕ2 , we find A3 ≈ 9.974 and ϕ3 ≈ −0.8395π which
mean the time shift is t3calculated = ϕ3 /2πf ≈ 0.0001049s which is near the above observed result of
both amplitude and time-shift ( or phase).
7
3 Complex Amplitude
x1 (t) can be initialized by the following code: