matlab beginner: use FFT in matlab and get phase plot
5 views (last 30 days)
Show older comments
Sorry for asking this question again, but i have to (so urgent)
i have some polymers characterized by transmission terahertz time domain spectroscopy (THz-TDS).
ive now the time domain data in Excel, with column A being (Delay ps), column B (Reference Amplitude nA), column C (Sample Amplitube nA) as follows.
i would like to have "FFT phase of column C" minus "FFT phase of column B", and then plot the phase (after deduction) as a function of frequency.
the following are the codes some nice people suggested.
[X,TXT,RAW] = xlsread('C:\Users\in Me u trust\Desktop\test\PP_1.CSV');
xdft = fft(X(:,2));
Nt = size(X,1); % Number of time samples
DT = X(2,1)-X(1,1);
Fs = 1/DT % sample frequency (= 1/dt)
df = Fs/Nt; % frequency increment
Nyq = Fs/2; % Nyquist frequency
if mod(Nt,2) == 0 % Nt is even
freq = ifftshift(-Nyq : df : Nyq-df);
else % Nt is odd
freq = ifftshift([sort(-1*(df:df:Nyq)) (0:df:Nyq)]);
end
xdft = xdft(1:length(xdft)/2+1);
phi = angle(xdft);
plot(freq,angle(fft(X(:,3)))-angle(fft(X(:,2))))
Anyway, these codes are collected from different people, and i as a beginner of Matlab just simply put them together so that they might not be coherent or what?? no idea and the question raised as follows.
so can anyone so nice to help perfect the code? thz in advance
0 Comments
Answers (2)
Ilham Hardy
on 15 Aug 2012
I just skimmed over your code. I think the problem lies in
plot(freq,angle(fft(X(:,3)))-angle(fft(X(:,2))))
it should looks
substr = angle(fft(x(:,3)))-angle(fft(x(:,2)));
plot(freq,substract);
will you give it a try?
HTH,
IH
0 Comments
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!