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:(2*pi+p);
fourier = 0;
for n=1:2:1000
m = n;
fourier_an = A*(2*sin(n*p)*cos(n*pi)-2*sin(n*p))*cos(n*t)/(n*pi);
fourier_bn = A*(2*cos(m*p)-2*cos(m*pi)*cos(m*p)+cos(m*p))*sin(m*t)/(m*pi);
fourier = fourier_an + fourier_bn + fourier;
end
plot(t,fourier);
Where did I mistake ?

As confirmed by @Piko, the problem is fixed by correcting $b_n$.
fourier_bn = A*(2*cos(m*p)-2*cos(m*pi)*cos(m*p))*sin(m*t)/(m*pi);Explanation
I spotted this because in the original Fourier coeffs, there is an asymmetry between the $a_n$ and $b_n$. As you can see, the length of the formula for $b_n$ is longer than that of $a_n$.
This looks suspicious. Upon inspection, this asymmetry is caused by an extra $\cos np$ term in $b_n$. After removing it, we plot the graph in Octave to see what we get, and indeed we get something looks like a square wave.