Prev: Matlab program to solve wave equation up to linear system of equations
Next: Polyfit and polyval doesn.t work for order greater than 9
From: fazleh on 21 May 2010 03:50 Hi I needed to plot the spectrogram of the tau_gate, frequency, and the Power. I have tried to get that but with fail. I even asked the same question in a previous thread but I was pointed the wrong direction. Really need help. Thanks in advance. CODE: Fs=800; t = -20:1/Fs:20; %Carrier Sine Wave lambda = 1550e-9; freq= ((3*10^8)/lambda)*1e-12; %Gaussian Function tau_pulse = 0; FWHM_pulse = 10; A_pulse = 1; sigma_pulse = FWHM_pulse/(2*sqrt(2*log(2))); Ip = A_pulse*exp(-((t-tau_pulse)/(2*sigma_pulse)).^2); %Gaussian input puls for tau_gate=-30:1:30; FWHM_gate = 10; A_gate = 1; sigma_gate = FWHM_gate/(2*sqrt(2*log(2))); SGorder_gate = 3; Ig = A_gate*exp(-((t-tau_gate)/(2*sigma_gate)).^(2*SGorder_gate)); %Gate % Plot pulse and gate intensities subplot(2,2,1) plot(t,Ip); xlabel('Time') ylabel('Amplitude') hold on plot(t,Ig,'r') hold off %Carrier And Gausian Ep = (sqrt(Ip).*cos(2*pi*freq*t)); Eo = Ig.*Ep; subplot(2,2,3) plot(t,Eo); axis([-20 20 -1.1 1.1]); xlabel('Time') ylabel('Amplitude') %Fourier Transform m = length(Ip);% Window length n = pow2(nextpow2(m)); % Transform length z = fft(Eo,n); % FFT z=fftshift(z);%Shift zero-frequency component of discrete Fourier transform to center of spectrum f=([-n/2:n/2-1]/n*Fs); power = z.*conj(z)/n; power = power./max(power); % PSD of the DFT figure(4); subplot(2,2,4) plot(f,power); axis([190 197 0 1.1]); xlabel('Frequency') ylabel('Power') pause(0.1) loopi =loopi + 1; end |