Numerical Methods using MATLAB 3. (50 pts.) (CC 4) Write a Matlab function that
ID: 1765939 • Letter: N
Question
Numerical Methods using MATLAB
3. (50 pts.) (CC 4) Write a Matlab function that calculates the real Discrete Fourier Transform according to the equations below, of a function given by a finite number of points. Name the Matlab function that you are writing, Real DFT INI(t,f where INI are your initials and t and fare vectors of the independent and dependent variables of data points, respectively 2N Ay=0 2N 0 2N f (t)) 2N 2nt2) k = 1,2, ,N-1 2TNt N-2N ft) cos The program should have the following features: i) Check to make sure that the user has entered an even number, 2N, of values (where N is an integer), and if not, must modify the input data by adding a zero entry at the end of f so that there are 2N values ii) Check to make sure that the data points are equally spaced. If not, the program should return an error message ii) Display stem plots or bar charts of Ak and Bk as a function of frequency vkk/T Execute this program for the following data: t (ms) 00.18018 0.36036 0.54054 0.72072 0.90090 1.081081.26126 1.44144 t -716 20 10 15 -3 16 This data represents sound pressure levels of a note played by an oboe. Can you guess what note is being played based on your results (the values of frequency of different notes can be found here: http://www.phy.mtu.edu/ suits/notefreqs html)?Explanation / Answer
N=4;
x=[2 3 -1 4];
t=0:N-1;
subplot(311)
stem(t,x);
xlabel('Time (s)');
ylabel('Amplitude');
title('Input sequence')
subplot(312);
stem(0:N-1,abs(fft(x)));
xlabel('Frequency');
ylabel('|X(k)|');
title('Magnitude Response');
subplot(313);
stem(0:N-1,angle(fft(x)));
xlabel('Frequency');
ylabel('Phase');
title('Phase Response');
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.