Numerical integration for nested integral

9 Ansichten (letzte 30 Tage)
Josh
Josh am 17 Sep. 2018
Bearbeitet: Josh am 18 Sep. 2018
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.
  2 Kommentare
Dimitris Kalogiros
Dimitris Kalogiros am 17 Sep. 2018
when you insert matlab code, use this button : {} Code
Josh
Josh am 17 Sep. 2018
It is corrected.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by