% Testing fourier Trasform
tmin=0;
%time_step=1e-9; 
time_step=1e-6; 
tmax=1e-3;
t=tmin:time_step:tmax;

N=length(t);
amp=2;
f1=50e3;
f2=50e6;
signal=amp.*sin(2*pi*f1.*t)+2.*amp.*sin(2*pi*f2.*t);
% Sawtooth wave
% Signal has a DC component of -28 dB if amp=2 (using mean(signal))
signal=amp.*sawtooth(2*pi*f1*t);
%signal=amp.*sawtooth(2*pi*f1*t)+amp.*sin(2*pi*f2.*t);
% Symmetric Saw tooth wave (triangle)
%signal=amp.*sawtooth(2*pi.*f1.*t,0.5);
% Square Wave
%signal=amp.*square(2.*pi.*f1.*t);

% Amplitude modulation
%fbase=1e4;
%signal=amp.*square(2.*pi.*fbase.*t).*sin(2*pi*f1*t);
%signal=amp.*sawtooth(2.*pi.*fbase.*t).*sin(2*pi*f1*t);


%figure;
%plot(t,signal);

fourier=fftshift(fft(signal))./N;

xx=real(fourier);
yy=imag(fourier);
mod=abs(fourier);
phase=angle(fourier);
mod_db=20.*log10(mod);

freq=-1./(2.*time_step):1./tmax:1./(2.*time_step);
figure;
plot(freq,mod_db)
%xlim([0 max(freq)])