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

Thank you Write a user-defined function called funct that takes two numbers x an

ID: 3534144 • Letter: T

Question


Thank you

Write a user-defined function called funct that takes two numbers x and N, where N is a positive integer and a real number in the interval (0 x 2pi). Your function should return the partial sum of cosines: Note that your function should print out a warning and exit if is not a positive integer. Then write a main program that takes five values of a in the interval (0 x 2pi). For each value of a, use your function funct to compute the partial sine cosine sum for N values from 1 to 100 and place your values in a vector. Also compute the quantity Q = pi2/6 - pix/2 + x2/4 and place you values in another vector. Plot both QN(x) and Q(x) versus N on the same axis. Label the x-axis "Number of terms, N", the y-axis "Partial Cosine Sum" and the title "Sinusoidal Series A". Remember to use legend to differentiate your plots and comment your program liberally. Next generate a vector of 200 values of x in the interval (0

Explanation / Answer

function Q = funct(x,N)

if N<1

disp('Wrong Input, Nshould be a positive integer')

else

Q=0

for k=1:N

Q=Q+ (cos(k*x)/(k^2))

end

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