% https://www.mathworks.com/help/matlab/ref/fft.html
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
% Beautiful square: theta redefined
theta = linspace(-2*pi, 2*pi, 1e5);
x2 = square(theta + deg2rad(15))/2 + square(theta - deg2rad(15))/2;
xlabel('\theta (\times\pi rad)')
% theta = linspace(-2*pi, 2*pi, 1e5)
P1(2:end-1) = 2*P1(2:end-1);
x2 = square(theta + deg2rad(15))/2 + square(theta - deg2rad(15))/2;
P1(2:end-1) = 2*P1(2:end-1);