From: vishal srivastava on
I am facing a problem when i am taking IFFT .By taking absolute fft i have got 4 peaks , i have to take ifft of positive output and get a different points at the spacing of different peaks but i am not getting that. Anybody can help me I am very thankful to him.
data_wave = xlsread('anub_data.xls');% Data is stored in Xl file
zr =300e-6;
rnm = 0;
rnmn = 0;
rn = 0;
r=zeros(1,609);
Ik = zeros(1,609);
J= zeros(609,609);
sk = data_wave(:,2)';
lamda = data_wave(:,1)';
f = 3e8./lamda;
k = ((2*pi).*1e9)./lamda;
zm = [10e-6,20e-6,25e-6,30e-6,40e-6];
for i=1:609
for m=1:5
for n=1:5
if m==n
%continue;
end
rnm = rnm + cos((2*k(i)*(zm(m)-zm(n)))*(180/pi));
end
end
for n=1:5
rn = rn + cos((2*k(i)*(zr - zm(n)))*(180/pi));
end

rnmn = rnmn + rnm + rn;

Ik(i) = sk(i)*(1+rnmn);
rnmn = 0;
rn = 0;
rnm=0;
end
y = fft(Ik,609);


m = abs(fftshift(y));
p = unwrap(angle(y));



subplot(2,1,1), plot(k,m);

ylabel('Abs. Magnitude'), grid on;

subplot(2,1,2), plot(k,p*180/pi);
ylabel('Phase [Degrees]'), grid on;

xlabel('Frequency [Hertz]');



figure(2);
h=ifft(m,[],609);
% o=abs(ifftshift(h));
plot(k,h);
From: Greg Heath on
On Apr 7, 2:42 am, "vishal srivastava" <anupeic16...(a)gmail.com> wrote:
>  I am facing a problem when i am taking IFFT .By taking absoluteffti have got 4 peaks  , i have to take ifft of  positive output and get a different points at the spacing of different peaks but i am not getting that. Anybody can help me I am very thankful to him.
-----SNIP

> y =fft(Ik,609);                        

OK. However, since length(lk) = 609, just use

y = fft(lk);

Only use the second input for zeropadding with
NFFT = 2^integer > 609, e.g,

y = fft(lk,1024);

or

y = fft(lk,2048);

Reread the fft documentation

doc fft
help fft


> m = abs(fftshift(y));                              
> p = unwrap(angle(y));                    
>
> subplot(2,1,1), plot(k,m);                
>
> ylabel('Abs. Magnitude'), grid on;
>
> subplot(2,1,2), plot(k,p*180/pi);        
> ylabel('Phase [Degrees]'), grid on;
>
> xlabel('Frequency [Hertz]');
>
> figure(2);
> h=ifft(m,[],609);
> % o=abs(ifftshift(h));

NO.

1. You can't ifft the magnitude, shifted or unshifted.
You need the unshifted complex transform y
2. The three input form is telling MATLAB to
ifft the 609th column of the matrix input m.
3. Reread the ifft documentation

doc ifft
help ifft

4. h = ifft(y) is complex with a tiny imaginary part.
Since you are trying to recover real lk, use

h = real(ifft(y));

check = max(abs(imag(ifft(y))))

> plot(k,h);

Hope this helps.

Greg