function [time,timeresp]=Time_Resp(freq,freqresp)
%This function returns the time response corresponding to the 
%fourier transform of freqresp
%
%freq are the frequencies over which freqresp occurs
%freqresp is a the frequency response

%fftshift the signal to get the correct phase
freqresp=fftshift(freqresp);
%zero pad the response to get higher time resolution
m=zeros(1,15*length(freqresp));
freqresp2=[freqresp m];
tresp=ifft(freqresp2);
tresp=fftshift(tresp);

%integral of x(t) is X(0) and 1/(time length of m) is time resolution
val=(sum(tresp))*(1/(length(freqresp2)*(freq(2)-freq(1))));
alpha=(freqresp(1)/val);
timeresp=tresp*alpha;
%check
(sum(timeresp))*(1/(length(freqresp2)*(freq(2)-freq(1))))
freqresp(1)
time=[0:length(freqresp2)-1]*(1/(length(freqresp2)*(freq(2)-freq(1))));