Igital Ignal Rocessing: Balochistan University of Information Technology, Engineering & Management Sciences-Quetta
Igital Ignal Rocessing: Balochistan University of Information Technology, Engineering & Management Sciences-Quetta
Session: Fall2019________
Date: __11-10-2019_______
TABLE OF CONTENTS
LAB’s
1. INTRODUCTION TO MATLAB
2. SIGNAL GENERATION
2.1. EXERCISE
other sounds. Musical notes that we find pleasing largely consist of pure tones near the pitch
of the musical note, but also contain other frequencies that give each instrument its particular
qualities. Voice and other natural sounds are also comprised of a number of pure tones.
Amazingly, all sounds can be built up out of pure tones, and likewise all-time signals can be
constructed by combining sinusoids. Similarly, starting with a general time signal, one can
break this signal down into its constituent sinusoids. How to do this and the consequences of
such constructions/decompositions is the subject of frequency domain analysis and Fourier
transforms.
MATLAB CODE:
Fs=1000; % sampling frequency
Ts=1/Fs; % Sampling Period or time step
dt=0:Ts:5-Ts; %signal Duration
f1=10;
f2=30;
f3=70;
%y=Asin(2pift+theta);
y1=10*sin(2*pi*f1*dt);
y2=10*sin(2*pi*f2*dt);
y3=10*sin(2*pi*f3*dt);
y4=y1+y2+y3;
% subplot(4,1,1);
% plot(dt,y1,'r')
% xlabel('Time [s]')
% ylabel('Amplitude')
% title('Y1')
% subplot(4,1,2);
% plot(dt,y2,'g')
% xlabel('Time [s]')
% ylabel('Amplitude')
% title('Y2')
% subplot(4,1,3);
% plot(dt,y3,'B')
% xlabel('Time [s]')
% ylabel('Amplitude')
% title('Y3')
% subplot(4,1,4);
% plot(dt,y4,'r')
% xlabel('Time [s]')
% ylabel('Amplitude')
% title('Y4=y1+y2+y3')
%It will be very difficult to find the frequency of y4, because it a time domain signal.
%so In order to find the frequency, we first have to know the length of time domain signal.
nfft=length(y4); %length of time domain signal
%to have a good frequency resulation in fft, the number of length of the signal must be equal
to 2 to the power of
nfft2=2^nextpow2(nfft); % length of signal in power of 2
ff=fft(y4,nfft2); % Fourier Transform, now the ff has magnitude as well as phase.
fff=ff(1:nfft2/2); % plot only 1 side of the signal
%plot(abs(fff))
%when we plot fff, we see on x-axix we have no of samples "0 to 4500", not frequency, so
we have to change this into frequency.
% Try to zoom one sample you will see the sample.
xfft=Fs*(0:nfft2/2-1)/nfft2; %xfft is the X-Axis and fff is the Y-Axis, both values must be
same in order to plot a graph
subplot(2,1,1);
plot(dt,y4,'g'); hold on
xlabel('Time [s]')
ylabel('Amplitude [V]')
title('Time Domain Signal'
subplot(2,1,2)
plot(xfft,abs(fff),'g');hold on % Magnitude plot
xlabel('Frequency [Hz]')
ylabel('Normilized Amplitude')
title('Frequency Domain Signal')
Output: