title: Drawing two same function, but looks different
body: <p>I have a problem with my project for studies.
  Here are the formulas
  <a href="https://i.stack.imgur.com/m8gab.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m8gab.jpg" alt="enter image description here"></a>, which I have to implement in Octave.
  First is called FCzase, second FSzereg. Both should give same output, but as you can see here
  <a href="https://i.stack.imgur.com/zukpF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zukpF.jpg" alt="enter image description here"></a>
  on plots, they are different. Something is wrong with FSzereg. Can someone, please, help me find my mistake?</p>
  
  <pre><code>U = 1;    #voltage
  T = 0.1;    #period
  f = 1/T;  #frequency
  n = 30;   #number of samples
  m = 30;  #number of components in Fourier function
  F1 = 0;
  F2 = 0;
  
  t= -T/2: T/n :T/2 - T/n + 2*T;
  w = 2*pi*f;
  
  for i = 1 : n
    if t(i) &lt; 0
      FCzasu(i) = -4*U*t(i)^2/T^2;
    else
      FCzasu(i) = 4*U*t(i)^2/T^2;
    endif
  endfor
  
  FCzasu = [FCzasu FCzasu FCzasu];
  
  for i = 2 : m
    F1 = F1 + (-1)^(i-1) * sin(i*w*t)/i;
  endfor
  for i = 1 : 2*m : 2
    F2 = F2 + sin(i*w*t)/i^3;
  endfor
  
  FSzereg = (2*U/pi)*(sin(w*t) + F1) - (8*U/(pi^3))*F2;
  
  FFTSzereg = abs(fft(FSzereg));
  FFTCzasu = abs(fft(FCzasu));
  
  k=0 : 1 : 3*n-1 ;
  fre = k * f/3;
  
  subplot(2,2,1)
  plot(t, FCzasu)
  xlabel('Czas [s]'); 
  ylabel('Napiecie [V]')
  
  subplot(2,2,2)
  stem(fre, FFTCzasu,'.')
  title('{\bf Widmo}');
  grid on;
  xlabel('Czestotliwosc [Hz]'); 
  ylabel('Amplituda [V]')
  
  subplot(2,2,3)
  plot(t, FSzereg)
  xlabel('Czas [s]'); 
  ylabel('Napiecie [V]')
  
  subplot(2,2,4)
  stem(fre, FFTSzereg,'.')
  title('{\bf Widmo}');
  grid on;
  xlabel('Czestotliwosc [Hz]'); 
  ylabel('Amplituda [V]')
  </code></pre>