Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Help: Finds difficult in solving this coupled ordinary differential equations using ODE45 ??

1 回表示 (過去 30 日間)
ruban ramalingam
ruban ramalingam 2019 年 6 月 26 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have been solving these coupled ordinary differential equations using ODE45
Function file (first file)
function dy=pair1(t,y)
dy=zeros(3,1);
dy(1)=(a/(1-y(3)).^b*sigma*(1-y(2))*coth(b*sigma*(1-y(2)))*sinh(b*sigma*(1-y(2))));
dy(2)=(hstress/sigma)*(1-(y(2)/hstar))*((a/(1-y(3)).^b*sigma*(1-y(2))*coth(b*sigma*(1-y(2)))*sinh((b*sigma*(1-y(2))))));
dy(3)=d*(a/(1-y(3)).^b*sigma*(1-y(2))*coth(b*sigma*(1-y(2))))*sinh(b*sigma*(1-y(2)));
end
Second file
a=0.2044e-6;
b=0.1855e-1;
d=1;
hstress=0.4285e05;
hstar=0.5113;
T=503;
sigma=180;
tspan=0:0.01:70;
initial_conditions=[0;0;0]; %change the intial condition according to your values
[t,y]=ode45(@(t,y)pair1(t,y),tspan,initial_conditions) %function call
plot(t,y)
Ended up in the following error:
Undefined function or variable 'a'.
Error in pair1 (line 3)
dy(1)=(a/(1-y(3)).^b*sigma*(1-y(2))*coth(b*sigma*(1-y(2)))*sinh(b*sigma*(1-y(2))));
Error in @(t,y)pair1(t,y)
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in Untitled6 (line 11)
[t,y]=ode45(@(t,y)pair1(t,y),tspan,initial_conditions) %function call
Please anyone help me to sort out this problem..

回答 (1 件)

Torsten
Torsten 2019 年 6 月 26 日
Put the constants (a,b,d,..) in your first file.
  1 件のコメント
madhan ravi
madhan ravi 2019 年 6 月 26 日
% changes to be made
function dy=pair1(t,y,a,b,d,hstress,hstar,T)
[t,y]=ode45(@(t,y)pair1(t,y,a,b,d,hstress,hstar,T),tspan,initial_conditions)

Community Treasure Hunt

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

Start Hunting!

Translated by