suggestion for the integrating the gaussian function
2 views (last 30 days)
Show older comments
Can someone help me with how to integrate the following Gaussian function over x whose range is [0 16]. The problem occurs when I try to shift the signal over time t which ranges t = (-1000:2:1000)*1e^-9 and t0 = 100e-12;
bt = 2*exp(-0.5*((t-((2*x)/(2e^8)))/t0).^2)*attn
I tried with quad and trapezoid. I am getting errors related to numerical integration. Any help is appreciated.
thanks
3 Comments
Accepted Answer
Daniel Shub
on 27 Jun 2011
I don't really understand the question. Your Gaussian function seems to depend on two variables (t and x). The t makes me think you want a 1D Gaussian. For the parameters you have given your sample rate on t is not high enough. If you plot bt, you just get a spike. Of course your parameters could be off since "1e^-9" and 2e^8 are not valid MATLAB syntax.
Once you figure out what you are trying to integrate and get your parameters correct, I would suggest
doc normcdf
or
doc erf
to do the integration. I believe they are optimized for intgrating a Gaussian.
3 Comments
Daniel Shub
on 27 Jun 2011
Your code is still not valid. The variable t is undefined and there is an extra "end" statement. The for loop also does not do anything, since you keep over writing bt. The function trapz is going to have problems since x is a scalar (equal to 16). Try simplifying your code by deleting everything that is not part of the problem. For example, I am guessing everything up to the for loop (and possibly the for loop) could be deleted and the definition of bt could be redefined without the variables Po, vroup, t0 and atten.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!