I am trying to find Fourier series of shifted square wave. I found $a_n$ and $b_n $ coefficients but when I draw it by matlab, unfortunately I don't get the right graph.
here the coefficients:
$$ a_n = \frac{A}{n \cdot \pi}\left( 2 \cdot \sin(n \cdot p) \cdot \cos(n \cdot \pi) - 2 \cdot \sin(n \cdot \pi) \right) $$
$$ b_n = \frac{A}{\pi \cdot n}\left( 2 \cdot \cos(n \cdot p)-2 \cdot \cos(n \cdot \pi) \cdot \cos(n \cdot p) + \cos(n \cdot p) \right) $$
p: shifting angle.

Here the codes that I used to draw graph
A = 12;
p =pi/6;
t = 0:0.001:(2pi+p);
fourier = 0;
for n=1:2:1000
m = n;
fourier_an = A(2sin(np)cos(npi)-2sin(np))cos(nt)/(npi);
fourier_bn = A(2cos(mp)-2cos(mpi)cos(mp)+cos(mp))sin(mt)/(mpi);
fourier = fourier_an + fourier_bn + fourier;
end
plot(t,fourier);
Where did I mistake ?

fourier_bn = A*(2*cos(m*p)-2*cos(m*pi)*cos(m*p))*sin(m*t)/(m*pi);– 光復香港 時代革命 Free Hong Kong Apr 17 '21 at 15:10