Numerical integration for nested integral

9 ビュー (過去 30 日間)
Josh
Josh 2018 年 9 月 17 日
編集済み: Josh 2018 年 9 月 18 日
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 件のコメント
Dimitris Kalogiros
Dimitris Kalogiros 2018 年 9 月 17 日
when you insert matlab code, use this button : {} Code
Josh
Josh 2018 年 9 月 17 日
It is corrected.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by