t = 0:.1:5*pi;

fokszam = 4;

y1 = zeros(1,length(t));
y2 = zeros(1,length(t));
y3 = ones(1,length(t))*2/pi;

for k = 1:fokszam
    n= 2*k-1;
    y1 = y1 + 2/(n*pi)*sin(n*pi/2)*cos(n*t);
    y2 = y2 - 4/(n*n*pi*pi)*cos(n*t);
    y3 = y3 - 4/pi/(4*k*k-1)*cos(k*t);    
end;

subplot(3,1,1); plot(t,y1);
subplot(3,1,2); plot(t,y2);
subplot(3,1,3); plot(t,y3);