www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/GaussianPulseExample.m
%% Gaussian Pulse % Convert a Gaussian pulse from the time domain to the frequency domain. % % Define signal parameters and a Gaussian pulse, |X|. % Copyright 2015 The MathWorks, Inc. Fs = 100; % Sampling frequency t = -0.5:1/Fs:0.5; % Time vector L = length(t); % Signal length X = 1/(4*sqrt(2*pi*0.01))*(exp(-t.^2/(2*0.01))); %% % Plot the pulse in the time domain. plot(t,X) title('Gaussian Pulse in Time Domain') xlabel('Time (t)') ylabel('X(t)') %% % To use the |fft| function to convert the signal to the frequency domain, % first identify a new input length that is the next power of 2 from the original % signal length. This will pad the signal |X| with trailing zeros in order to % improve the performance of |fft|. n = 2^nextpow2(L); %% % Convert the Gaussian pulse to the frequency domain. Y = fft(X,n); %% % Define the frequency domain and plot the unique frequencies. f = Fs*(0:(n/2))/n; P = abs(Y/n); plot(f,P(1:n/2+1)) title('Gaussian Pulse in Frequency Domain') xlabel('Frequency (f)') ylabel('|P(f)|')