1 / 7

Lecture 20: Trigonometric interpolations

Lecture 20: Trigonometric interpolations. Download triginterp.m. Calculate trig interpolation at interval [t0, tn] In p points based on interpolation in n points. t0=-10; tn=10; n=50; p=n*10; t=t0+(tn-t0)*(0:n-1)/n; % n evenly-spaced time points

melba
Télécharger la présentation

Lecture 20: Trigonometric interpolations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 20: Trigonometric interpolations Download triginterp.m Calculate trig interpolation at interval [t0, tn] In p points based on interpolation in n points

  2. t0=-10; tn=10; n=50; p=n*10; t=t0+(tn-t0)*(0:n-1)/n; % n evenly-spaced time points tp=t0+(tn-t0)*(0:p-1)/p; % p evenly-spaced time points f = inline('exp(-t.^2)'); %test function to interpolate x=f(t); xexact=f(tp); y=fft(x); % apply DFT yp=zeros(p,1); % yp will hold coefficients for ifft yp(1:n/2+1)=y(1:n/2+1); % move n frequencies from n to p yp(p-n/2+2:p)=y(n/2+2:n); % same for upper tier xp=real(ifft(yp))*(p/n); % invert fft to recover data error=xp-xexact'; subplot(2,1,1); plot(t,x,'o',tp,xp) % plot data points and interpolant title('trigonometric nterpolation'); subplot(2,1,2); plot(tp,error,'o') % plot error title('error')

  3. Gibb’s phenomenon %Example of Gibb's phenomenon - failure of trig interpolation for nonperiodic functions t0=0; tn=10; n=50; p=n*10; t=t0+(tn-t0)*(0:n-1)/n; % n evenly-spaced time points tp=t0+(tn-t0)*(0:p-1)/p; % p evenly-spaced time points f = inline('exp(-t.^2)'); %test function to interpolate x=f(t); xexact=f(tp); y=fft(x); % apply DFT yp=zeros(p,1); % yp will hold coefficients for ifft yp(1:n/2+1)=y(1:n/2+1); % move n frequencies from n to p yp(p-n/2+2:p)=y(n/2+2:n); % same for upper tier xp=real(ifft(yp))*(p/n); % invert fft to recover data error=xp-xexact'; subplot(2,1,1); plot(t,x,'o',tp,xp) % plot data points and interpolant title('trigonometric nterpolation'); subplot(2,1,2); plot(tp,error,'o') % plot error title('error')

  4. Download triginterpgibbs.m

  5. Inclass • Interpolate function exp(-x^4) at interval [-10,10] from • 50 equally spaced points. Plot your result.

More Related