[t,y]=textread('fourier_hw1.txt','%f%f','headerlines',1);
figure(1)
plot(t,y)

T=max(t)
wo=2*pi/T
df=wo/(2*pi)
dt=t(2)-t(1)
fs=1/dt
f=0:df:fs;
fn=fs/2;%Nyquist frequency - fft mirrors about this
N=length(y);

YF=fft(y)*2/N;

figure(2)
plot(f,real(YF))
xlim([0,20])

figure(3)
plot(f,imag(YF))

%zoom in on Figure(2) to find that
a1=2.6
f1=5.2
test=a1*cos(2*pi*f1*t);
figure(1)
plot(t,y,t,test)


%or
ind=abs(YF)>0.00001;
an=YF(ind)
fn=f(ind)