%HW1, problem 2, MAE200B, winter 2006, Nasser Abbasi
%Print fouier approximation to initial coditions for
%different n (number of terms expansion)

close all; clear all;
L=2;
x=linspace(0,L,10000);
y=zeros(length(x),1);
y=1000;

maxN=1000;
for n=1:2:maxN
    y=y-(4000/pi)*(1/n)*sin(n*pi/4)*cos(n*x*pi/4);
end
plot(x,y)
y(1:length(x)/2)=0;
y(length(x)/2:end)=1000;
hold on;
plot(x,y,'r');
title(sprintf('Fourier approximation, n=%d',maxN));
xlabel('x');
ylabel('V(x,0) approximation');