I want to make this MATLAB code to plot a Gaussian pulse in THz, then use FFT on it. This is the MATLAB code I used to get the FFT of time domain Gaussian signal at 800nm wavelength:
lambda= 800e-9;%Wavelength c=3*10.^8;%lLight speed fc = c/lambda; % Actual Frequency of light [THz] fsamp=fc*10; %sampling frequency fs=1/fsamp; %Unit Time in [fs] Ls=200; %Length of signal sigma=8e-15;% Pulse duration ts=(0:Ls-1)*fs; %time base t0 = max(ts)/2; % Used to centering the pulse gauss = (exp(-2*log(2)*(ts-t0).^2/(sigma)^2)).*cos(-2*pi*fc*(ts-t0)); subplot(2,1,1) plot(ts,real(gauss),'b'); title('Gaussian Pulse in Time Domain'); xlabel('Time(s)'); ylabel('Amplitude'); grid on; NFFT = 2^nextpow2(Ls); X = fft(gauss,NFFT)/Ls; freq = 0.5*fsamp*linspace(0,1,NFFT/2+1); % (full range) Frequency Vector subplot(2,1,2) plot(freq,abs(X(1:NFFT/2+1))) title('FFT of the Gaussian Pulse'); xlabel('Frequency (Hz)') ylabel('Magnitude |X(f)|'); grid on;
Which will give:
However, when I change the wavelength to 30um, it will give me a different shape:
I know this is due the pulse duration (sigma), or maybe entirely wrong code. How do I make it retain its shape whenever I change the wavelength, without continuously changing the pulse duration?