for J=[1 3 7 29 99] 
    
    X_J = 4*sin(J*pi/2)*exp(1j*pi/2*(J-1))/(J^2*pi^2);
    B_J = 2*X_J;
    Jterm = B_J .* cos(J*2*pi*(-0.5:0.0001:0.5)); %ypologizoume ton J-oro tou athroismatos se xrono mias periodou
    
    figure; subplot(2,1,1);
    plot(-0.5:0.0001:0.5,Jterm);
    ylabel(['B[' int2str(J) '] cos(' int2str(J) 'w0t)']);
    
    s = 0;
    
    %ypologizoume to x_j
    xj = 0;
    for k=1:J
        Xk = 4*sin(k*pi/2)*exp(j*pi/2*(k-1))/(k^2*pi^2);
        Bk = 2*Xk;
        
        xj = xj + Bk.*cos(k*2*pi*(-0.5:0.0001:0.5)); %ypologismos tou xj se xrono mias periodou
    end
     
    subplot(2,1,2);
    plot((-0.5:0.0001:0.5),xj); 
    ylabel(['{x}_{' int2str(J) '}(t)']);
end