fs = 1e6;
fx = fs/21;
N  = 50;

t1 = linspace(0, (N-1)/fs, N);
y1 = sin(2*pi*fx*t1);

figure(1);
plot(t1, y1, 'rx', t1, y1, '-');
xlabel('Time');
ylabel('Signal Amplitude');
fixfig;

figure(2);
s1 = 20*log10(abs(fft(y1)/N/2));
s1 = s1(1:N/2);
f1 = (0:length(s1)-1) / N;
subplot(2, 1, 1);
plot(t1, y1);
xlabel('Time');
ylabel('Signal Amplitude');
fixfig;
subplot(2, 1, 2);
plot(f1, s1, '-', f1, s1, 'rx');
xlabel('Frequency  [ f / f_s ]');
ylabel('Amplitude  [ dBFS ]');
fixfig;

t2 = t1(end)+T:T:2*C/fx-T;
t2a = t2 - t2(1);
t2b = t2;

y2a = sin(2*pi*fx*t2a);
y2b = sin(2*pi*fx*t2b);

figure(3);
subplot(2, 1, 2);
plot(t1, y1, t2, y2a, 'r', [t1(end) t2(1)], [y1(end) y2a(1)], 'r');
xlabel('Time');
ylabel('Signal Amplitude');
fixfig;
subplot(2, 1, 1);
plot(t1, y1, t2, y2b, 'r', [t1(end) t2(1)], [y1(end) y2b(1)], 'r');
xlabel('Time');
ylabel('Signal Amplitude');
fixfig;

figure(4);
subplot(2, 1, 1);
plot(t1, y1, t2, y2a, 'r', [t1(end) t2(1)], [y1(end) y2a(1)], 'r');
xlabel('Time');
ylabel('Signal Amplitude');
fixfig;
subplot(2, 1, 2);
y2a_= [y1 y2a];
N_  = length(y2a_);
s2a = 20*log10(abs(fft(y2a_)/N_/2));
s2a = s2a(1:N_/2);
f2a = (0:length(s2a)-1) / N_;
plot(f2a, s2a, '-', f2a, s2a, 'rx');
xlabel('Frequency  [ f / f_s ]');
ylabel('Amplitude  [ dBFS ]');
fixfig;

figure(5);
subplot(2, 1, 1);
plot(t1, y1, t2, y2b, 'r', [t1(end) t2(1)], [y1(end) y2b(1)], 'r');
xlabel('Time');
ylabel('Signal Amplitude');
fixfig;
subplot(2, 1, 2);
y2b_= [y1 y2b];
N_  = length(y2b_);
s2b = 20*log10(abs(fft(y2b_)/N_/2));
s2b = s2b(1:N_/2);
f2b = (0:length(s2b)-1) / N_;
plot(f2b, s2b, '-', f2b, s2b, 'rx');
xlabel('Frequency  [ f / f_s ]');
ylabel('Amplitude  [ dBFS ]');
fixfig;

