2024 Lec 01 Shared
2024 Lec 01 Shared
?
% s2 plotted as discrete time signal
subplot (223); % 3rd graphic window is selected
stem(t,s2); % plot of discrete samples
axis ([0 0.1 -0.6 0.6]); xlabel('time in second'); ylabel('amplitude');
title('discrete time signal using sin function, F=50Hz, Fs=1000 Hz')
% Verifying two discreet time sinusoids are same if frequencies are F and (F+Fs)
[s4, t4] = mysin (0.5, 1050, 1000, 0.1); % A=0.5, F=1050. Fs=1000, T=0.1
subplot (224); stem(t4, s4); axis ([0 0.1 -0.6 0.6]);
xlabel('time in second'); ylabel('amplitude');
title('A=0.5, F=1050 Hz, Fs=1000 Hz, T=0.1 sec')
Anything wrong anywhere?
Anything wrong anywhere?
Digital Signal
A/D D/A
Digital Processing Digital
Analog Analog
signal signal signal signal
2𝜋𝜋 𝑓𝑓 + 𝐹𝐹 𝑛𝑛
𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴 2𝜋𝜋(𝑓𝑓 + 𝐹𝐹)𝑡𝑡 → 𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴
𝐹𝐹
F=50. Fs=1000
2𝜋𝜋𝜋𝜋𝜋𝜋
= 𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴 + 2𝑛𝑛𝑛𝑛 F=1050. Fs=1000
𝐹𝐹
How will F=950. Fs=1000 look like?
% Here we write a function mysquare.m that reconstructs a square wave from its
% Fourier coefficients. T0 = Time period of square wave, n= No. of harmonics used
function [s,t]=mysquare(T0,n)
s=0;
for i=1:n
j=2*(i-1)+1; % Only odd harmonics of sin function are present
s=s+(4*sin(2*pi*F0*j*t))/(pi*j); % Weighted sum from Fourier expansion
end
% Exp. 3
% Use function mysquare.m to see addition of weighted sinusoids give a square wave
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
For matrices, fftshift(X) swaps the first quadrant with the third and
the second quadrant with the fourth.
>> help square
square Square wave generation.