Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a MATLAB user-defined function that calculates the real Discrete Transform

ID: 3674004 • Letter: W

Question

Write a MATLAB user-defined function that calculates the real Discrete Transform of a function given by a finite number of points. Name the function Real_DFT(t,f) where the input arguments t and f are vectors with the values of the independent and dependent variables of the data points, respectively. The program should have the following features

1. 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 for f so that there are 2N values.

2. check to make sure that the data points are equaly spaced. If not the program should output an error message.

3. display stem plots of Ak and Bk as a function of frequency vk=k/(tau). Execute the program for the following data:

t: 0 0.25 0.5 0.75 1 1.25 1.5 1.75 2

f(t):   0 0.25 0.5 0.75 1 1.25 1.5 1.75 2

Explanation / Answer

function Real_DFT(t,f)
   x = size(t,2);
   y = size(f,2);
   if (x != y || x%2 != 0)
       fprintf("each must contain an even number ");
   else
       for i = 2:x-1
           if (t[i+1] - t[i] != t[i] - t[i-1])
               fprintf("t is not evenly distributed ");
               return;
           end
       end
       for i = 2:y-1
           if (f[i+1] - f[i] != f[i] - f[i-1])
               fprintf("f is not evenly distributed ");
               return;
           end
       end
   end
   plot(t,f);
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote