Lab2 (1) 2
Lab2 (1) 2
clc
clear
close all
SamplingFrequency = 300;
SamplingInterval = 0:1/SamplingFrequency:10 ; %% Time period = 1/Fs where FS
is the sampling frequency
Figure 1
Q2: Part A
clc
clear
close all
SamplingFrequency = 300;
TimeVector = 0:1/SamplingFrequency:10 ; %% Time period = 1/Fs where FS is the
sampling frequency
FsA = 10;
TimeVectorA = 0:1/FsA:10 ; %% Time period = 1/Fs where FS is the sampling
frequency
xA = 2 + 6*cos(20*pi*TimeVectorA) + cos(40*pi*TimeVectorA); %% This is the
variable holding the signal
FsB = 15;
TimeVectorB = 0:1/FsB:10 ; %% Time period = 1/Fs where FS is the sampling
frequency
xB = 2 + 6*cos(20*pi*TimeVectorB) + cos(40*pi*TimeVectorB); %% This is the
variable holding the signal
FsC = 20;
TimeVectorC = 0:1/FsC:10 ; %% Time period = 1/Fs where FS is the sampling
frequency
xC = 2 + 6*cos(20*pi*TimeVectorC) + cos(40*pi*TimeVectorC); %% This is the
variable holding the signal
FsD = 40;
TimeVectorD = 0:1/FsD:10 ; %% Time period = 1/Fs where FS is the sampling
frequency
xD = 2 + 6*cos(20*pi*TimeVectorD) + cos(40*pi*TimeVectorD); %% This is the
variable holding the signal
FsE = 60;
TimeVectorE = 0:1/FsE:10 ; %% Time period = 1/Fs where FS is the sampling
frequency
xE = 2 + 6*cos(20*pi*TimeVectorE) + cos(40*pi*TimeVectorE); %% This is the
variable holding the signal
% Tile 1
nexttile
plot(TimeVectorA,xA);
axis([0 0.2 -5.0 10]) %% limit the range
xlabel('Time (s)')
ylabel('Amplitude (V)')
title('Analog signal for Fs = 10')
% Tile 2
nexttile
plot(TimeVectorB,xB);
axis([0 0.2 -5.0 10]) %% limit the range
xlabel('Time (s)')
ylabel('Amplitude (V)')
title('Analog signal for Fs = 15')
% Tile 3
nexttile
plot(TimeVectorC,xC);
axis([0 0.2 -5.0 10]) %% limit the range
xlabel('Time (s)')
ylabel('Amplitude (V)')
title('Analog signal for Fs = 20')
% Tile 4
nexttile
plot(TimeVectorD,xD);
axis([0 0.2 -5.0 10]) %% limit the range
xlabel('Time (s)')
ylabel('Amplitude (V)')
title('Analog signal for Fs = 40')
% Tile 5
nexttile
plot(TimeVectorE,xE);
axis([0 0.2 -5.0 10]) %% limit the range
xlabel('Time (s)')
ylabel('Amplitude (V)')
title('Analog signal for Fs = 60')
% Tile 6
nexttile
plot(TimeVector,x);
axis([0 0.2 -5.0 10]) %% limit the range
xlabel('Time (s)')
ylabel('Amplitude (V)')
title('Analog signal for Fs = 300')
Q2: Part B
clc
clear
close all
figure
tiledlayout(3,2); % Using the command 'tiledlayout' to plot the 6 figures instead
of subplot
figure
tiledlayout(3,2); % Using the command 'tiledlayout' to plot the 6 figures instead
of subplot
nexttile
pwelch(X,[],[],[],SamplingFrequency);