Forums

using IFFT in matlab

Started by rongfenc March 4, 2002
I meet a problem which is to convert a signal from frequency domain
into time domain. I tried to use IFFT to convert it but I did not
succeed.
If you are interested, please see the following matlab code
Thank you!

function calculate_TimeVariation(N,OR,M,Dop_res,res_accu)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N = 10;
OR = 4;
M = 256;
Dop_res = 0.1;
res_accu = 20;
%%%%%%%%%%%%%%%
P = [0 -5 -10];
K = [1 0 0];
tau = [0.0 0.5 1.0];
Dop = [0.4 0.4 0.4];
ant_corr = 0.4;
Fnorm = -1.5113;
%%%%%%%%%%%%%%%%%%%%%
P = 10.^(P/10);
s2 = P./(K+1);
m2 = P.*(K./(K+1));
m = sqrt(m2);
%%%%%%%%%%%%%%%%%%%%%
L = length(P);
paths_r = sqrt(1/2)*(randn(L,N) +
j*randn(L,N)).*((sqrt(s2))'*ones(1,N))
paths_c = m'*ones(1,N)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%
for p = 1:L
D = Dop(p)/max(Dop)/2
f0 = [0:M*D]/(M*D);
PSW= 0.785*f0.^4 - 1.72*f0.^2 +1.0;
filt = [PSW(1:end-1) zeros(1,M - 2*M*D) PSW(end:-1:2)];
%define S(f)
filt = ifftshift(ifft(filt));
filt = real(filt);
filt = filt/sqrt(sum(filt.^2));
path = fftfilt(filt, [paths_r(p,:) zeros(1,M)]);
paths_r(p,:) = path(1+M/2:end-M/2);
end;
paths = paths_r + paths_c;
paths = paths*10^(Fnorm/20)
%Pest = mean(abs(paths).^2, 2)
%fprintf('tap mean power level: %0.2f dB\n', 10*log10(Pest));
figure, psd(paths(1,:), 52, max(Dop));

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%the above is the original code and the following code is I add
t = 0:0.4/512:0.4
P = ifftshift(ifft(PSW));
plot(length(t)-1, PSW)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%