Lab #2 Discrete-time Fourier Transform (DTFT) OBJECTIVES:
• Explore the DTFT, its meanings and concepts. • Get acquainted with Matlab/Octave
1) Start MATLAB and change the “Current Directory” in the top of the window (or type) >> cd '' (example: >> cd 'C:\NIU\lab2') Alternatively, if you don't want to use MATLAB, you can open a web-browser and go to “octave-online.net”.
2) Download and execute LAB2forStudent_A.M with >> lab2forStudent_A and observe that it produces a Discrete-Time (DT) signal xVec.
3) TO DO: Replace the 1st line “if (0)” with “if (1)”, and add lines to compute the DTFT of the signal xVec at w=π/10 (note: in Matlab/Octave, the word “pi” to represent π; thus, you can use w=pi/10). Store the value of X(exp(jw)) for w=pi/10 it in a variable bigX. TIP: Recall the formula for the DTFT of a signal x[n]: NOTE: it is okay to use a FOR LOOP for this task.
4) Execute the script again and observe the value of the variable bigX.
5) If you don't obtain bigX = 40.000 + i (a very small value); STOP and double check your code.
6) TO DO: Replace the 2nd line “if (0)” with “if (1)”. Surround the code that you used to compute the DTFT with an outer FOR LOOP to compute the DTFT various values of w. (Use wVec defined in the script)
7) Execute the script again. You should see a plot of the absolute values of the DTF
8) QUESTION: Considering that xVec contains the samples of a periodic continuous-time signal x(t) sampled with a sampling frequency of 1,000 samples/second, change the line that plots the DTFT so that the x-axis shows frequency components in Hz.
10) Download and execute the script lab2forStudent_B.m. >> lab2forStudent_B
11) TO DO: Replace the 1st line “if (0)” with “if (1)”, and copy the part of the code of PART-A into the script lab2forStudent_B.m in order to compute the DTFT of the signal xVec of PART-B for various values of w
12) Observe the values of the 1st 10 entries of the vector bitXvec, which stores the computed values of the DTFT. >> bigXvec(1:10)
14) TO DO: To better observe the DTFT, add lines to the script to plot the MAGNITUDE and the PHASE graphs of the DTFT. In Matlab/Octave, the commands abs(aVec) and angle(aVec) respectively give the magnitude and the phase of a complex value (or vector) aVec.
16) Re-open the script lab2forStudent_A.m and change the number of samples as below: nVec=0:45; Save the code and re-execute.
lab2forStudnent_A:
clear all %clears the memory
close all %close all figures
nVec=0:39;
xVec=2*cos(2*pi*nVec*0.05);
figure(1);
stem(nVec,xVec);
if(1)
w=pi/10;
bigX = 0;
%Note that we define nVec=0:39 above. The purpose of this
vector
%is to create a vector with the time index of each sample in the
signal xVec.
%we will use this vector to compute the DTFT.
%(You could also obtain the time of each sample directly from the
looping variable (k). It is a matter of taste. In my opinion
keeping a separate vector with the sample indexes or times keep the
code more organized.)
%%%%%%%%%%% FOR STUDENT:
%%%%%%%%%%%
%%%%%%%%%%% add lines to compute the DTFT of the signal xVec at
w=pi/10
%%%%%%%%%%% NOTE: it is okay to use a FOR LOOP for this task.
disp(sprintf('X(exp(jw)) for w=pi/10 is '))
disp(bigX)
end
%compute DTFT
if (0)
%%%%%%%%%%% FOR STUDENT:
%%%%%%%%%%%
%%%%%%%%%%% Copy and change the lines that you used above to
compute
%%%%%%%%%%% the DTFT of xVec so that you compute for every w inside
wVec below
wVec=[-2.5:0.05:2.5]*pi;
bigXvec = zeros(1,length(wVec)); %this creates a vector to store
the DTFT for each value of w
%%% START HERE: build a loop over all the w's inside wVec
figure(2);
fs = 1000;
grid on;
plot(wVec,abs(bigXvec),'ro');
xlabel('normalized angular frequency (radians/second)')
end
lab2forStudent_B:
clear all %clears the memory
close all %close all figures
nVec=0:50;
for j=1:length(nVec)
if nVec(j) < 10
xVec(j) = 1;
else
xVec(j) = 0;
end
end
figure(1);
stem(nVec,xVec);
if (1)
%%%%%%%%%%% FOR STUDENT:
%%%%%%%%%%%
%%%%%%%%%%% copy the part of the code of PART-A that computes the
DTFT for
%%%%%%%%%%% several values of w below the definition of wVec.
wVec=[-2.5:0.01:2.5]*pi;
%%%%%%%%%% FOR STUDENT:
%%%%%%%%%% add lines to plot the MAGNITUDE and the PHASE graphs of
the DTFT.
%%%%%%%%%% In Matlab/Octave, the commands abs(aVec) and angle(aVec)
respectively give the magnitude and the phase of a complex value
(or vector) aVec.
end
nVec=0:39;
xVec=2*cos(2*pi*nVec*0.05);
figure(1);
stem(nVec,xVec);
if(1)
w=pi/10;
bigX = 0;
%Note that we define nVec=0:39 above. The purpose of this
vector
bigX=0; %Initialize bigX value to zero
N=length(xVec); %Find the size of xVec
w=pi/10;
for n=1:N
bigX=bigX+xVec(n)*exp(-1j*w*(n-1)); % Compute the DTFT at
w=pi/10;
end
disp(sprintf('X(exp(jw)) for w=pi/10 is '))
disp(bigX)
end
%compute DTFT
if (1)
wVec=[-2.5:0.05:2.5]*pi;
bigXvec = zeros(1,length(wVec)); %this creates a vector to store
the DTFT for each value of w
for n=1:N
bigX=bigX+xVec(n)*exp(-1j*wVec*(n-1)); % Generate DTFT signal
end
figure(2);
fs = 1000;
grid on;
plot(wVec,abs(bigXvec),'ro');
xlabel('normalized angular frequency (radians/second)')
end
Output:
X(exp(jw)) for w=pi/10 is
40.0000 + 0.0000i
Second Program:
clear all %clears the memory
close all %close all figures
nVec=0:50;
for j=1:length(nVec)
if nVec(j) < 10
xVec(j) = 1;
else
xVec(j) = 0;
end
end
figure(1);
stem(nVec,xVec);
if (1)
N=length(xVec); %Find the size of xVec
wVec=[-2.5:0.01:2.5]*pi;
bigXvec = zeros(1,length(wVec)); %this creates a vector to store
the DTFT for each value of w
for n=1:N
bigXvec=bigXvec+xVec(n)*exp(-1j*wVec*(n-1)); % Compute the DTFT at
w=pi/10;
end
%%%%%%%%%% FOR STUDENT:
%%%%%%%%%% add lines to plot the MAGNITUDE and the PHASE graphs of
the DTFT.
%%%%%%%%%% In Matlab/Octave, the commands abs(aVec) and angle(aVec)
respectively give the magnitude and the phase of a complex value
(or vector) aVec.
figure(2)
plot(wVec,abs(bigXvec),'ro');
figure(3)
plot(wVec,angle(bigXvec),'ro');
end
Output:
Now Change nVec=0.45 in first plot
The outputs are:
Lab #2 Discrete-time Fourier Transform (DTFT) OBJECTIVES: • Explore the DTFT, its meanings and concepts. •...
Matlab Question#1: Determine the discrete-time Fourier transform of x(n) (0.8y'n u(n)+(0.1)'n u(n) Evaluate Xei) at 501 equispaced. points between [0,pi] and plot its magnitude, angle, real, and imaginary parts Matlab Question#2: Determine the discrete-time Fourier transform of Evaluate Xei) at 1001 equispaced points between [0pi] and plot its magnitude, angle, real, and imaginary parts. Matlab Question#3: Compute the FT values at the prescribed frequency points and plot the real and imaginary parts and the magnitude and phase spectrums. The FT...
Exercises: u used to the instructor b the end of next lab. 20 102 Plot the f(t)-sinc(20r) cos(300t)sinc (10t) cos(100t) Use the fast Fourier transform to find the magnitude and phase spectrum of the signal and plot over an appropriate range. Use appropriate values for the time interval and the sampling interval. Note that in Matlab sinc(x)-, so we need to divide the argument by n to make it match the given function. Le, sinc(20t/pi) Hint: Use the parameters from...
This is a MATLAB Question. Below is my base code for a Fourier Series of a half triangle wave. So I am being asked to isolate the first 8 components so that only those first 8 components of the half triangle function are calculated by MATLAB fft function, and then afterwards I am asked to do the same thing but with the first 20 components rather than the first 8. How do I isolate the first x number of components...
Exercise 4. Computing and displaying the Fourier Transform of a signal Later in the semester it will become useful to determine the frequency response of a signal or system by taking the Fourier Transform empirically (rather than computing it analytically). To do so we make use of the fft and fftshift commands. The fft command is an efficient implementation of the Discrete Fourier Transform (DFT) known as the Fast Fourier Transform (FFT). When the FFT is computed the samples are...
1. For each of the following choices of r(n) and N, you will perform the five tasks stated below (a) x(n (b) r(n)-2-a(n), Л-16, (d) x(n) is same as in part (c) with N = 8 otherwise Task 4: Compute DTFT of y. You may not be able to obtain a closed form expression for the DTFT of y. However since y has finite duration of length N, you can just code the analysis equation in Matlab. Let y(k 1)...
Can you please help me answer Task 2.b? Please show all work. fs=44100; no_pts=8192; t=([0:no_pts-1]')/fs; y1=sin(2*pi*1000*t); figure; plot(t,y1); xlabel('t (second)') ylabel('y(t)') axis([0,.004,-1.2,1.2]) % constrain axis so you can actually see the wave sound(y1,fs); % play sound using windows driver. %% % Check the frequency domain signal. fr is the frequency vector and f1 is the magnitude of F{y1}. fr=([0:no_pts-1]')/no_pts*fs; %in Hz fr=fr(1:no_pts/2); % single-sided spectrum f1=abs(fft(y1)); % compute fft f1=f1(1:no_pts/2)/fs; %% % F is the continuous time Fourier. (See derivation...
CS240 Intro Engineering Programming Programming Assignment # 6 Due Friday, March 29th by midnight Topics: Plot subplot We know that the work done by a force F which is applied on a box at an angle x-axis and a displacement value d is given by: with respect to the and assume we know that d 15 m. Write a function its name is "work calculator" which gets two inputs 1) A vector which includes angle( θ ) values ranges from...
During lab 4, we have seen numerical implementation of Fourier Series for periodic signals. As first part of this assignment, you need to write a Matlab function that would take an array representing a single period of a signal (x), corresponding time array (t), and return the Fourier Series coefficients (Ck) in exponential form. The function should also be able to take two (2) optional input arguments: number of Fourier coefficients (Nk) and plot option (p). Use the template ‘fourier_series_exp.m’...
matlab help, please my code is here: %% exercise2 %a Fs = 8000; % sampling frequency tn = 0:1/Fs:0.005; % here, bit duration is 0.005s instead of 1/300s phi1 = 0; phi0 = 0; % phases of the sinusoid x1 = cos(2*pi*1650*tn + phi1); % tone for binary 1 x0 = cos(2*pi*1850*tn + phi0); % tone for binary 0 xx = [x1, x0]; % FSK signal for ¡°1,0¡± tt = [tn, tn + 0.005]; % time figure(1) plot(tt, xx); %...
This is taken from Section 4.6, "Amplitude Modulation and the Continuous-Time Fourier Transform," in the course text Computer Explorations in signals and systems by Buck, Daniel, Singer, 2nd Edition. I need the answers for the basic and intermediate questions. 4.6 Amplitude Modulation and the Continuous-Time Fouriei Transform This exercise will explore amplitude modulation of Morse code messages. A simple ampli tude modulation system can be described by x(t) = m(t) cos(Crfot), (4.13) where m(t) is called the message waveform and...