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

Assume that the coefficients required to implement the summation are known. Coef

ID: 1992849 • Letter: A

Question

Assume that the coefficients required to implement the summation are known. Coefficients of Cn and On are stored in vectors of length N+1. Variable t=0:Tsample:Tmax, tmax is some multiple of the period of the signal. Write a MATLAB function called harmonic to generate the signal r(t). The inputs to this function should be the scalar w0, containing the fundamental frequency, the vectors Cn, thetan, the maximum time tmax, and the sampling interval Tsample. The output of the function should be the vector r containing the signal r(t) sampled at the specified values of time t. Your function may use either a for loop or a matrix multiply to implement the summation. If you use a for loop, only one such loop should be necessary.

n cos nwo n=0

Explanation / Answer

function r=harmonic(w0,Cn,thetan,Tmax, Tsample)
t=0:Tsample:Tmax;
r=zeros(size(t));
for n=1:length(Cn)
r=r+Cn(n).*cos((n-1).*w0.t+thetan(n-1));
end
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