Ex1_12

# Ex1_12 - for k = 1:nterm cwt = cos(k*omega*tcycle(i swt =...

This preview shows page 1. Sign up to view the full content.

tau = 2; npts = 1000; ncycle = 5; nterm = 50; Y = 0.1; omega = 2*pi/tau; dt = tau/npts; d aa = 0; a = zeros(nterm,1); b = zeros(nterm,1); t = [0:dt:tau]; for i = 1:npts+1 f(i) = Y*t(i)/tau; aa = aa + 2/tau*f(i)*dt; for k = 1:nterm cwt = cos(k*omega*t(i)); swt = sin(k*omega*t(i)); a(k) = a(k) + 2/tau*f(i)*cwt*dt; b(k) = b(k) + 2/tau*f(i)*swt*dt; end end aa a b pause; p ef = zeros(ncycle*npts+1,1); ef = ef + aa/2*ones(ncycle*npts+1,1); tcycle = [0:dt:ncycle*tau]; for i = 1:ncycle*npts+1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for k = 1:nterm cwt = cos(k*omega*tcycle(i)); swt = sin(k*omega*tcycle(i)); af(i) = Y*mod(tcycle(i),tau)/tau; ef(i) = ef(i) + a(k)*cwt + b(k)*swt; end end e subplot(2,1,1) plot(tcycle,af,'--') axis([0 5*tau -0.02 0.12]) xlabel('t') ylabel('periodic function') subplot(2,1,2) plot(tcycle,ef) axis([0 5*tau -0.02 0.12]) xlabel('t') ylabel('Fourior series approximation') title('Comparison between af and ef')...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern