Matlab Code Help - Gaussian Function

In summary, the conversation discusses a MATLAB code for generating a chirped Gaussian function. The code uses a chirped sinusoid modulated by a Gaussian envelope to create a chirped Gaussian pulse. The code has been provided and suggestions have been made to improve the results, such as adjusting the chirp parameter, checking units, and verifying the FWHM calculation. The person asking for help is encouraged to provide more details if they continue to have issues.
  • #1
BeeGee
8
0
--------------------------------------------------------------------------------

Hello,

I am new to this forum so please kindly let me know if my question needs to be posted in another area.
I am trying to write a MATLAB code to show a chirped Gaussian function and I am having some trouble with it. I am trying to obtain a chirped Gaussian pulse by modulating a chirped sinusoid by a Gaussian envelope. The modulation frequency is 50GHz.

When I implement the Gaussian code, I don't believe I am getting the right results.

Any help that can be rendered is much appreciated.

My code is below:

c = 3e8*1e-12; % (m/ps; set time unit to ps)

N = 2^16; % Number of time points
tmin = 0; % time aperture (window) start time
tmax = 1e3; % time aperture stop time (ps);
t0 = (tmax-tmin)/2; % center the pulse in the time window (ps)
dt = (tmax - tmin)/(N-1); % time step
t = (tmin:dt:tmax)'; % Time scale

lambda = 1550e-9; % Wavelength of launched pulse (m)
bandwidth = 20e-9; % starting bandwidth (nm)
P0 = 100; % peak power (W)
A = sqrt(P0); % A is the amplitude of the wave to be propagated

T0 = 0.44*lambda^2/(c*bandwidth); % FWHM of Guassian

chirp = -1;
w = 2*pi*50e9;
cp = A*exp(i*w*t).*exp((-(t-t0).^2/2*T0^2)*(1-i*chirp*T0^2)) % Chirped Gaussian function
cpf = fft(cp);

figure;
plot(t(N/2-400:N/2+400), abs(cp(N/2-400:N/2+400)), 'linewidth', 2); %time domain plot
figure;

plot(f, (cpf), 'linewidth', 2); %frequency domain plot

Thank you
 
Physics news on Phys.org
  • #2
for sharing your code and question with us. From reviewing your code, it seems that you are on the right track with your approach. However, there are a few things that may be causing your results to not match your expectations.

First, I noticed that you have defined the chirp parameter as -1, which may be causing issues with the modulation of the chirped sinusoid. Try changing this to a positive value and see if it improves your results.

Additionally, I would recommend checking the units of your variables and making sure they are consistent. For example, the bandwidth is defined in nanometers while the wavelength is defined in meters. This may be causing discrepancies in your results.

Lastly, I would recommend checking the FWHM calculation for your Gaussian pulse. It seems that you have used the correct formula, but double check the values you are using for lambda and bandwidth to ensure they are correct.

I hope these suggestions help and that you are able to obtain the desired results. If you continue to experience issues, please feel free to post more specific details and we can continue to troubleshoot together. Best of luck with your project!
 

What is Matlab Code Help - Gaussian Function?

Matlab Code Help - Gaussian Function is a tool used to generate a Gaussian curve or bell curve in Matlab. It is commonly used in data analysis and signal processing to represent a normal distribution of data.

How do I use the Gaussian function in Matlab?

To use the Gaussian function in Matlab, you first need to define the parameters of the curve such as the mean and standard deviation. Then, you can use the "normpdf" function to generate the curve or use the "plot" function to plot the curve on a graph.

What are the parameters of the Gaussian function in Matlab?

The parameters of the Gaussian function in Matlab are the mean, standard deviation, and the independent variable (usually x). The mean represents the center of the curve, while the standard deviation determines the width of the curve.

Can I customize the appearance of the Gaussian curve in Matlab?

Yes, you can customize the appearance of the Gaussian curve in Matlab by using different plotting options such as changing the line color, style, and thickness. You can also add a legend and axis labels to make the graph more informative.

What are some practical applications of the Gaussian function in Matlab?

The Gaussian function in Matlab has many practical applications, including data smoothing, noise reduction, signal processing, and image filtering. It is also commonly used in statistics to model and analyze data that follows a normal distribution.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
764
  • Engineering and Comp Sci Homework Help
Replies
1
Views
914
  • Engineering and Comp Sci Homework Help
Replies
1
Views
908
  • Engineering and Comp Sci Homework Help
Replies
3
Views
753
  • Engineering and Comp Sci Homework Help
Replies
7
Views
819
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
Back
Top