% Script File: square
% Plots the trigonometric interpolant.
function aliasing()
clear
M=20
A = linspace(0,1,2*M+1)';
D = sinwave(A,4,6,20);
%D(2:M)=-1;D(M+2:2*M)=1;D(1)=0;D(M+1)=0;D(2*M+1)=0;
%=[ 408 89 -66 10 338 807 1238 1511 1583 1462 1183 804 408]';
D=D';

Avals = linspace(0,1,1000)';
Dvals = sinwave(Avals,4,6,10);
%F     = CSInterp(D(1:2*M));
%Fvals = CSeval(F,360,Avals);
%F = fft(D);
fvals = interpft(D(1:2*M),1000);
xx=linspace(0,1,1000);

%plot(Avals,Fvals,A,D,'o')
plot(Avals,Dvals,'r-',xx,fvals,'b-')
%plot(Avals,Fvals,Avals,fvals,'r')
%a = 170;b=235;
%axis([a b .985 1.035])
a=0;b=360;
set(gca,'xTick',linspace(a,b,M/4))
%xlabel('Ascension (Degrees)')
%ylabel('Declination (minutes)')

function y = sinwave(x,a,b,c)
y = sin(2*pi*a*x)+3*cos(2*pi*b*x)-12*sin(2*pi*c*x);