suggestion for the integrating the gaussian function

3 次查看(过去 30 天)
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 个评论
Neels
Neels 2011-6-27
thanks for the response. the following is my code, i am trying to mimic the propagation of light in optical fiber.x refers to the distance. I want the signal to attenuate gradually till the particular time x at the same time i want the signal to be shifted to mimic the delay in the propagation.
clc
clear all
global Po C m t0 taum dtau tunit tau vgroup alpham attn L N
% declared global to try with quad, but it was showing errors
Po= 4; % [mW] initial peak power of signal source
C = 0; % Chirping Parameter
m = 1; % Super Gaussian parameter (m=1 ==> Gaussian)
t0 = 100e-12; %[sec] initial pulse width
vgroup= 2e8;
alpham=0.24;
attn=0.24;
taum = 10000;
dtau = 2*taum/2^12; %1.953
tunit= 1e-12; % make time unit in psec
tau = (-1000:dtau:(taum-dtau))*tunit; %
% fs = 1/(dtau*tunit);
at = sqrt(Po)*exp(-0.5*(1+i*C)*(tau/t0).^(2*m)) % Input field in the time domain
subplot(2,2,1);
plot(tau,at);
title('input wave');
for x=0:16
%bt = sqrt(Po)*exp(-0.5*((tau*x)/t0).^2)*attn
bt = sqrt(Po)*exp(-0.5*((t-((2*x)/vgroup))/t0).^2)*attn
subplot(2,2,2)
plot(x,bt,'-rx');
end
end
l=trapz(x,bt);
subplot(2,2,3);
plot(t,l,'-rx');

请先登录,再进行评论。

采纳的回答

Daniel Shub
Daniel Shub 2011-6-27
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 个评论
Daniel Shub
Daniel Shub 2011-6-27
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.
Neels
Neels 2011-6-27
yes mate,I agree with you. I was experimenting with the code the t should be tau. sorry for that. I am trying to shift the Gaussian pulse and attenuate it. I have trimmed the code below.
global Po C m t0 taum dtau tunit tau vgroup alpham attn L N
Po= 4; % [mW] initial peak power of signal source
C = 0; % Chirping Parameter
m = 1; % Super Gaussian parameter (m=1 ==> Gaussian)
t0 = 100e-12; %[sec] initial pulse width
vgroup= 2e8;
taum = 10000;
dtau = 2*taum/2^12; %1.953
tunit= 1e-12; % make time unit in psec
tau = (-1000:dtau:(taum-dtau))*tunit; %
at = sqrt(Po)*exp(-0.5*(1+i*C)*(tau/t0).^(2*m))
subplot(2,2,1);
plot(tau,at);
title('input wave');
for x=0:16
bt = sqrt(Po)*exp(-0.5*((tau-((2*x)/vgroup))/t0).^2)*exp(3.84)
subplot(2,2,2)
end
l=trapz(x,bt);
subplot(2,2,3);
plot(t,l,'-rx');

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by