필터 지우기
필터 지우기

How to integral function and plot it

조회 수: 1 (최근 30일)
Tina Hsiao
Tina Hsiao 2021년 6월 21일
댓글: Star Strider 2021년 6월 25일
Hi, Could you help me how to integral function "fun" and get the q, then plot dL vs q. The code as below. Thanks a lot.
clear all; close all; clc
Gamma = 1;
kappa = 0.75*Gamma;
Dp = 0*Gamma;
Dc = 0*Gamma;
Finese = 350;
OD0 = 0.025;
OD = (Finese/pi)*OD0;
G = OD;
Oc = 2*Gamma;
Op = 0.00001*Gamma;
T0 = 1;
rR = 0*Gamma;
dL = linspace(-6*Gamma,6*Gamma,2000);
kappat = -i*kappa/2+Dp-dL-df;
Gammat = -i*Gamma/2-dL-df;
gammat = -i*rR/2+Dc-dL-df;
Gammaf = 0.00001*Gamma;
A = -4*gammat.*Gammat;
T = T0*(kappa/2)^2.*...
abs((A+Oc^2)./((G^2*gammat)+(kappat.*(A+Oc^2)))).^2;
fun = @(df) (exp(-(df^2/Gammaf^2))/(sqrt(pi)*Gammaf))*T;
q = integral(fun,-Inf,Inf)
figure(1)
plot(dL, q)
xlabel ('dL')
ylabel('Transmission signal')
  댓글 수: 2
Sergey Kasyanov
Sergey Kasyanov 2021년 6월 21일
편집: Sergey Kasyanov 2021년 6월 21일
Are kappat, Gammat, gammat functions of df?
What is dL? Why is it array?
Tina Hsiao
Tina Hsiao 2021년 6월 23일
Yes! kappat, Gammat, gammat are functions of df. The dL is an array once I get the q result. I would like to put all the value (eg. Gamma = 1; kappa = 0.75*Gamma; Dp = 0*Gamma; Dc = 0*Gamma; ...etc into q and with different dL. And plot dL vs q.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2021년 6월 23일
kappat, Gammat, gammat are functions of df.’
I created them (as well as ‘A’, ‘T’, and ‘fun’) as anonymous functions of ‘df’ to define them as such.
Check this to be certain it prooduces the desired result, otherwise make necessary corrections (since I do not understand what this code does) —
Gamma = 1;
kappa = 0.75*Gamma;
Dp = 0*Gamma;
Dc = 0*Gamma;
Finese = 350;
OD0 = 0.025;
OD = (Finese/pi)*OD0;
G = OD;
Oc = 2*Gamma;
Op = 0.00001*Gamma;
T0 = 1;
rR = 0*Gamma;
dL = linspace(-6*Gamma,6*Gamma,2000);
kappat = @(df) -i*kappa./2+Dp-dL-df;
Gammat = @(df) -i*Gamma./2-dL-df;
gammat = @(df) -i*rR./2+Dc-dL-df;
Gammaf = 0.00001*Gamma;
A = @(df) -4*gammat(df).*Gammat(df);
T = @(df) T0*(kappa/2)^2.*...
abs((A(df)+Oc^2)./((G^2*gammat(df))+(kappat(df).*(A(df)+Oc^2)))).^2;
fun = @(df) (exp(-(df.^2./Gammaf^2))./(sqrt(pi)*Gammaf)).*T(df);
q1 = integral(fun,-Inf,0, 'ArrayValued',1);
q2 = integral(fun,0,Inf, 'ArrayValued',1);
q = q1 + q2;
figure(1)
plot(dL, q)
xlabel ('dL')
ylabel('Transmission signal')
Since ‘q’ as originally defined is uniformly 0, I broke it into two regions and added them.
.
  댓글 수: 2
Tina Hsiao
Tina Hsiao 2021년 6월 25일
Prima! Thanks a lot...I like this solution.
Star Strider
Star Strider 2021년 6월 25일
As always, my pleasure!
Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Gamma Functions에 대해 자세히 알아보기

태그

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by