Numerical integration for nested integral

9 vues (au cours des 30 derniers jours)
Josh
Josh le 17 Sep 2018
Modifié(e) : Josh le 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 commentaires
Dimitris Kalogiros
Dimitris Kalogiros le 17 Sep 2018
when you insert matlab code, use this button : {} Code
Josh
Josh le 17 Sep 2018
It is corrected.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by