Numerical integration for nested integral

9 次查看(过去 30 天)
I want to calculate the ratio G(t) between the two functions B(t) and A(t) at each time step from t=1 to 2500 using MATLAB.
Here j,m,b,d,e,g,h are constants.
I have written following Matlab code for this problem:
Functionscript.m
b=0.0001;
m=0.2331;
j=-0.2323;
d=0.1719;
e=-4.5000;
g=0.1719;
h=0.2355;
T=2500;
[G]=QM(b,m,j,d,e,g,h,T);
========================================
function [G]=QM(b,m,j,d,e,g,h,T)
G=zeros(T);
A=@(t) j-m*coth((m/2)*(t-T)+acoth((j-b)/m));
I=@(t,s) exp(integral(@(u) -A(u)-h,t,s));
SI=@(t,s) I(t,s)*(A(s)*e-g);
B=@(t) I(t,T)*d-integral(@(s) SI(t,s),t,T,'ArrayValued',1);
G(1)=B(1)/A(1);
for i=1:T
G(i)=B(i)/A(i);
end
When i run this code the values that I get don't change much over time, I think it is probably because the numerical integration of nested integral is not working correctly. Could anyone please check?. Thank you.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by