%% Time transform function : takes frequency and phases and output the signal in time.

function[time,signal,signal2] = TimeTransform(freq,amp,phase)

n= length(freq);
fstep = (freq(n)-freq(1))/(n-1);

amp=10.^(amp/20);

temp = amp.*exp(1i*(phase/180*pi));

%signal = abs(ifft(cat(2,temp,fliplr(temp))));
%signal =(ifft(temp));
signal=real(ifft([linspace(0,(freq(1)-fstep),freq(1)/fstep)';temp],length(temp)+1));
signal2=real(ifft(cat(2,([linspace(0,(freq(1)-fstep),freq(1)/fstep)';temp]),fliplr([linspace(0,(freq(1)-fstep),freq(1)/fstep)';temp]))));

time   = 1/fstep*linspace(0,1,n+1);

figure(121)
plot(time,2*signal)




