# Write a MATLAB script to compute and plot one period of f_m(t) by adding up to n = 25

1 view (last 30 days)
Genosphere on 8 Jul 2020
Commented: Genosphere on 9 Jul 2020
Hello all, I having some trouble figuring out the code par of this lab, assuming my inital work on the first part is correct. Kind of have something that looks like its working just dont think its exactly right. Ill post what I have so far followed by the instructions. If someone point out anything that look wrong or sugestions that would be great.
Thanks
T
This is just part of it and its just replicated with different values so this should suffice.
syms n t
for w0=pi; To=1; ee=exp(-t); n=1:5;
a0=(1/To)*int(ee,t,0,1)
an=(2/To)*int(ee*cos(n*w0*t),t,0,1)
bn=(2/To)*int(ee*sin(n*w0*t),t,0,1)
end
fmt=(a0/2)+an+bn;
plot(n, fmt); grid
1. Write a title and short description of this lab on a new page ofyour lab book.
2. MATLAB cannot reconstruct a continuous time signal, but ifwe compute discrete points at a step size ofabout
1/16fmax, we will get a fairly good representation of the continuous signal.
3. In this case, we shall use a maximum of25 harmonics n ≤ 25.
4. good choice of step size, then, is 0.01. (Since the period of this signal is 1, you will want about 200 data points
to display one period.)
EDIT:
So i did some researchin(googling) and some playing around and redid the code. The images below are of my signals and new code. Looks alot better, but still unsure if im "correct".
With n= 1:5
With n= 1:100

John D'Errico on 9 Jul 2020
Without even looking at any code, it "looks" pretty dead on as I would expect. The ringing at those corners - this is a classical Fourier series phenomena.
Genosphere on 9 Jul 2020
Cool!