suggestion for the integrating the gaussian function

3 ビュー (過去 30 日間)
Neels
Neels 2011 年 6 月 27 日
コメント済み: anu chauhan 2016 年 6 月 12 日
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');
anu chauhan
anu chauhan 2016 年 6 月 12 日
also i am working with same problem kindly help me

サインインしてコメントする。

採用された回答

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 Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by