matlab beginner: use FFT in matlab and get phase plot
5 ビュー (過去 30 日間)
古いコメントを表示
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.
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
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.
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
so can anyone so nice to help perfect the code? thz in advance
0 件のコメント
回答 (2 件)
Ilham Hardy
2012 年 8 月 15 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spectral Measurements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!