You are on page 1of 6

PRE LAB TASK#1

CODING:
clear all;
close all;
clc;
N=128;n=0:N-1;fnd=3/N;
x=sin(2*pi*fnd*n)+sin(2*3*pi*fnd*n)/3+sin(2*pi*5*fnd*n)/5+si
n(2*pi*7*fnd*n)/7;
DFT3D_1(x)
rotate3d on

function DFT3D_1(x)
N=length(x);
n=0:N-1;
%x=x.*(hamming(N));
X=fft(x)*2/N;
X1=abs(X')*ones(1,N);X1=X1';
f=(0:N-1)/N; % Harmonics
[ff,nn]=meshgrid(f,n);
W=cos(2*pi*f'*n);
X1=W'.*X1;
X1(:,1)=x;
plot3(ff,nn,X1,'LineWidth',2);grid on
xlabel('frequency');
ylabel('time seconds');
axis([0 1 0 N -1.3 1.3]);
view([37.5 30])
PLOTS


PRE LAB TASK #2
CODING:

clear all;
close all;
clc;
t = [-10 : 0.001 : 10]; % step size - so small to
approximate cont time
Tp = 1; % Time Period of the signal
tau = 0.5; % Pulse Width - Duty Cycle
Fo = 1/Tp; % Fundamental Frequency
x=(1+square(2*pi*Fo*t,tau*100))/2; % Generating pulse
train signal
figure,
plot(t,x,'Linewidth',2);
xlabel('secs');
ylim([-1.2 1.2]);
grid;
pause; % Press any key
% Extracting a portion of the signal equal to its
period.
time_period = find(t == -Tp/2) : find(t == Tp/2);
x_period = x(time_period ); % functional values in one
periodic interval
figure,
plot(t(time_period),x_period,'Linewidth',2);
xlabel('secs');
ylim([-1.2 1.2]);
grid
pause % Press any key
% Computing CTFS Coefficients
for k = 1:25
B = exp(-j*2*pi*(k-1)*Fo.*[-Tp/2:0.001:Tp/2]);
% basis function for CTFS
C(k) = sum(x_period.*B)/(length(x_period)*Tp);
end
kFo = Fo*[0:k-1]; % Frequency Scale in Hz.
figure,
stem(kFo,abs(C),'filled','Linewidth',2);
title('CTFS Coefficients');
xlabel('Frequency (Hz)');
grid
(a) As pulse-width decreases, the zero crossings in frequency domain starts to go farther away from each other, or we
can say that lobe-width start to expand.
(b) The signal with higher data rate will occupy more bandwidth, because it will contain more amount of frequency
content compared to the signal having slower data rate.
(c) If the digital signals are transmitted using their line-coded rectangular shaped form, they will occupy a very large
bandwidth, and it is always desired to have a band-limited signals for transmission. Modulating the signal using either
scheme (ASK, PSK or FSK) makes the signal band-limited to their carrier frequency.

PLOTS:





Tau= 0.1 k=25 Tau= 0.5 k=25









Tau= 0.01 k=50
Tau= 0.001 k=100
IN LAB TASK:
CODING:
% Matlab code for drawing the spectrum of a rectangular pulse.
% The program shows a rectangular pulse of varying duration and its
spectrum
% The programe demonstrates inverse relationship between the pulse width
and the mainlob bandwidth
function RectPuls_Sinc()
%Set the Samplig Frequency
Fs=1;
T0=0.002; % Pulsewidth T.
t=-1:.01:1;
size(t)
N=1000; %Number of frequency samples N.
df=1; %Frequency resolution for plot df, frequency range -Ndf/2 < f <
Ndf/2
for k=1:200
T=k*T0;
x=rectpuls(t,T);
for i=1:N/2-1
X(i)=T*sin(pi*T*df*(i-N/2))/(pi*T*df*(i-N/2));
X(N-i)=T*sin(pi*T*df*(N-i-N/2))/(pi*T*df*(N-i-N/2));
end
X(N/2)=T;
figure(1)
subplot(2,1,1)
plot(t,x);
title 'Rectangular Pulse'
axis([min(t), max(t), min(x)-.1,max(x)+.1])
subplot(2,1,2)
plot(X);
title 'Sinc Function'
axis([1, 1000, -0.1,.42])
pause(0.02);
end

PLOTS:

If the period of observation in time-domain in increased, the certainty of frequency content viewable in
frequency domain increases. This could be verified by looking at the plots shown above; when the pulse-width
(period of observation) in time-domain in widened, the lobe-width is decreased and thus frequency content
viewable in frequency-domain is increased.

POST LAB TASKS:

1. Why do we need to plot magnitude spectrum and phase spectrum separately?
We need to plot magnitude spectrum and phase spectrum separately because in this way we can clearly
observe the strength of each harmonic component present in the signal.
2. Why a simple positive frequency sine wave shows a phase angle of -90 degrees in the phase spectrum?
This is because a simple sine wave is composed of two complex conjugate exponentials, one (negative
frequency exponential) having amplitude involving +j while other (positive frequency exponential) having
amplitude involving -j. The later one will be having a phase-angle of -90 degrees in phase-spectrum.
Using Eulers identity, sine wave can be expressed as into exponential wave by following relation:



Due to this -, the positive frequency has the phase spectrum of -90
0
.

You might also like