use FFT in matlab and get phase plot

3 Ansichten (letzte 30 Tage)
Passband  Modulation
Passband Modulation am 14 Aug. 2012
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), column C (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.
i am told this could be done by adding
plot(freq,angle(fft(X(:,3)))-angle(fft(X(:,2))))
after
[X,TXT,RAW] = xlsread('yourfile.xls');
xdft = fft(X(:,2)); xdft = fft(X(:,2));
% sampling interval -- assuming equal sampling
DT = X(2,1)-X(1,1);
% sampling frequency
Fs = 1/DT;
DF = Fs/size(X,1);
freq = 0:DF:Fs/2;
xdft = xdft(1:length(xdft)/2+1); phi = angle(xdft);
anyway it does not work
the command window shows
??? Error using ==> plot Vectors must be the same lengths.
Error in ==> Untitled at 12 plot(freq,angle(fft(X(:,3)))-angle(fft(X(:,2))))
  2 Kommentare
Michael Quinn
Michael Quinn am 14 Aug. 2012
Not knowing your data size/shape, I can only offer some suggestions on what to look at. Instead of your plot() command, make a new variable:
PhaseDifference = angle(fft(X(:,3)))-angle(fft(X(:,2)));
Then look at its size compared to the size of freq:
size(PhaseDifference)
size(freq)
It looks like (from the error) that they are different. You'll need to figure out how to fix this so that you can successfully plot them.
Passband  Modulation
Passband Modulation am 15 Aug. 2012
thank you Michael Quinn, but i am not familiar with this. anway thx again.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Dr. Seis
Dr. Seis am 14 Aug. 2012
Bearbeitet: Dr. Seis am 14 Aug. 2012
Here are the frequencies associated with the output from FFT:
Nt = % Number of time samples
Fs = % 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
Then you can just do a xlim on the plot to zoom in on a specific frequency range.
  1 Kommentar
Passband  Modulation
Passband Modulation am 15 Aug. 2012
Bearbeitet: Passband Modulation am 15 Aug. 2012
really thx a lot. these are the background info and the related questions on them.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by