Numerical integration for nested integral

9 visualizzazioni (ultimi 30 giorni)
Josh
Josh il 17 Set 2018
Modificato: Josh il 18 Set 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 Commenti
Dimitris Kalogiros
Dimitris Kalogiros il 17 Set 2018
when you insert matlab code, use this button : {} Code
Josh
Josh il 17 Set 2018
It is corrected.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by