HW3Sol

# HW3Sol - Recall that you must calculate Co separately and...

This preview shows pages 1–11. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
% Plot the approximation given by the truncated Fourier series N = [0 1 2 3 4 10]; x = linspace(-5,5,100); Lambda = [2 4 2 2]; functionlabel = [ 'a' 'b' 'c' 'd' ]; for i1 = 1:length(Lambda) figure; titletext = sprintf( 'Function %c)' ,functionlabel(i1)); for i2 = 1:length(N) FN = zeros(size(x)); for m = -N(i2):N(i2) cm = [exp(-i*m*pi/2)/2*sinc(m/2) i*pi*m/2*exp(-i*pi*m/2)*sinc(m/2)^2 i/pi if m==0 cm(3)=0; end % needed because MatLab gives NaN for zero/zero FN = FN + cm(i1)*exp(i*2*pi*m*x/Lambda(i1)); end subplot(length(N),1,i2); plot(x,real(FN)); set(gca, 'XTick' ,[min(x):max(x)]) if i2 == 1 title(titletext) end end end function s=sinc(arg) s=sin(pi*arg)/(pi*arg); if arg == 0 s = 1; end if mod(arg,1) == 0 s = 0; end if arg == 0 s = 1; end

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
clear all clc p = -10:0.01:10; a = 1; % define functions from problem #1 fa = 1./sqrt(2.*pi).*sinc(a.*p./2./pi); fa10 = fa.^10; fb = a./sqrt(2.*pi).*(sinc(a.*p./2./pi)).^2; fb10 = fb.^10; fc = sqrt(2./pi).*a./(a.^2+p.^2); fc10 = fc.^10; % define Gaussians we are going to compare
This is the end of the preview. Sign up to access the rest of the document.

## This document was uploaded on 03/23/2011.

### Page1 / 12

HW3Sol - Recall that you must calculate Co separately and...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online