# THz-TDS Fast Fourier Analysis in MATLAB

Hello,

Basically I have some Terahertz time-domain-spectroscopy which I'm trying to analyse.

The data that I have has Voltage and "Delay length" within the array.

Apparently I can convert the delay length to a time using t=(delay length)/c. Then I can do a fast fourier transform in MATLAB to swap things to the frequency domain.

The column with the voltage data I have is called 'V' and I just fft(V); however, the data Iget out is strange. My final plot should be amplitude on the y afis and frequency along the x axis.

Has anyone done anything like this before? Am I supposed to use both vectors in the array to do the transform?

Best wishes

Hi Pene1 (curious name, by the way)

I found this topic searching for other step in this long process of THz-TDS, but I might be able to help you at this step.

The data that you obtain after executing fft(V) is the Spectrum, but with the frequencies disorganized due to the internal behavior of the FFT algorithm.
In order to short them you should use the command:
>> fftshift(fft(V)/npoints);
After this you'll obtain the spectrum properly organized and with the correct magnitude (check the normalization by npoints)
Another thing that you should consider is what you want to obtain. I assume that you want to obtain the power spectrum.
This spectrum should be
>> abs(fftshift(fft(V)/npoints));

I hope you'll find this usefull
regards

Super helpful thanks; I do have another query... my fft gives complex numbers, I read somewhere that to get the power spectrun you multiply by the complex conjugate in order to get a real number - is that what you have done?

I might be able to help with your step if you let me know what's troubling you?

Hi Pene1 (curious name, by the way)

I found this topic searching for other step in this long process of THz-TDS, but I might be able to help you at this step.

The data that you obtain after executing fft(V) is the Spectrum, but with the frequencies disorganized due to the internal behavior of the FFT algorithm.
In order to short them you should use the command:
>> fftshift(fft(V)/npoints);
After this you'll obtain the spectrum properly organized and with the correct magnitude (check the normalization by npoints)
Another thing that you should consider is what you want to obtain. I assume that you want to obtain the power spectrum.
This spectrum should be
>> abs(fftshift(fft(V)/npoints));

I hope you'll find this usefull
regards

FFT is an application over a complex space. Don't worry about the imaginary part because physics uses to happen in ℝ^3 and you should take the modulo of the data (in matlab is the built in function "abs"). Unpleasantly there are several options to take the modulo or magnitude of the signal (I discovered it in Origin's Lab help).

Luckily I solved my problem, but thank you in any case.
Recently we started with a THz-TDS system from Ekspla and I wanted to reproduce their data to check my algorithm.
This guys gave you the power spectrum normalized as MSA (Mean Squared Amplitude) or that is what I think after looking for more information.
So that the power spectrum can be evaluated as follows:
let me suppose that X=fftshift(fft(V))/nptos

>>PowerSpectrum=abs(X)=sqrt(real(X).^2+imag(x).^2)/nptos;

>>PoweSpectrum(as MSA)=(real(X).^2+imag(x).^2)/nptos^2;