MATLAB Answers

0

ode45 code not running and need help imputing my boundary conditions

Daniel Kubiat さんによって質問されました 2019 年 3 月 15 日
最新アクティビティ Torsten
さんによって コメントされました 2019 年 3 月 15 日
here is my matlab function code and the error i keep getting when running it also i would like to know how and where i can put my boundary condition in this code
function ydot = kubieode(t, y )
%define variables making it more legible
% Numerical Integration of Differential Equation
% Numerical Integration of a 3rd order ODE using ODE45 solver embedded in
% MATLAB.
%Pr is the Prantl number of the concerned fluid respectively.
%Le: Lewis number
%Nb: Brownian motion parameter
%Nt: Thermophoresis parameter
Msq = 0.5;
Nt = 0.1;
Nb = 0.1;
Pr = 0.2;
Le = 1.0;
ydot = zeros(7, 1); % Pre-allocate
ydot(1) = y(2); % f '
ydot(2) = y(3); % f ''
ydot(3) = -y(1) * y(3) + Msq * y(2); % f''' = -y(1)*y(3) + 0.5*y(2 )
ydot(4) = y(5); % theta '
ydot(5) = -Pr * (Nb * y(7) * y(5) + Nt * y(5) * y(5)); % theta ''
ydot(6) = y(7); % psi '
ydot(7) = - (Nt/Nb) * ydot(5) - (Le/Nb) * y(1); % psi ''
end
HERER IS THE COMMAND WINDOW AND RESULT/ERROR
y0(1) = 0 % f
y0(2) = 0 % f'
y0(3) = 0 % f''
y0(4) = 0 % theta
y0(5) = 0 % theta'
y0(6) = 0 % psi
y0(7) = 0 % psi'
[t y] = ode45(@kubieode,[0,20],y0);
[t,y]; %to print
plot(t,y(:,1));
y0 =
0 0 0 0 0 0 0
y0 =
0 0 0 0 0 0 0
y0 =
0 0 0 0 0 0 0
y0 =
0 0 0 0 0 0 0
y0 =
0 0 0 0 0 0 0
y0 =
0 0 0 0 0 0 0
y0 =
0 0 0 0 0 0 0
Msq =
0.5000
Nt =
0.1000
Nb =
0.1000
pr =
0.2000
le =
1
??? Undefined function or variable 'y0'.
Error in ==> kubieode at 30
[t,y] = ode45('kubieode',[0,20] ,y0);
Error in ==> odearguments at 110
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ==> ode45 at 173
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

  3 件のコメント

Torsten
2019 年 3 月 15 日
If you start with y0=0, y will be 0 for all times.
Daniel Kubiat 2019 年 3 月 15 日
so what do i start with? and how do i impute my boundary conditions to this code
Torsten
2019 年 3 月 15 日
See the code below on how to input your boundary conditions.
It's up to you to know which boundary conditions to take.

サインイン to comment.

1 件の回答

回答者: Torsten
2019 年 3 月 15 日
 採用された回答

function main
y0=zeros(7,1);
y0(1) = 0; % f
y0(2) = 0; % f'
y0(3) = 0; % f''
y0(4) = 0; % theta
y0(5) = 0; % theta'
y0(6) = 0; % psi
y0(7) = 0; % psi'
[t y] = ode45(@kubieode,[0,20],y0);
plot(t,y(:,1));
end
function ydot = kubieode(t, y )
%define variables making it more legible
% Numerical Integration of Differential Equation
% Numerical Integration of a 3rd order ODE using ODE45 solver embedded in
% MATLAB.
%Pr is the Prantl number of the concerned fluid respectively.
%Le: Lewis number
%Nb: Brownian motion parameter
%Nt: Thermophoresis parameter
Msq = 0.5;
Nt = 0.1;
Nb = 0.1;
Pr = 0.2;
Le = 1.0;
ydot = zeros(7, 1); % Pre-allocate
ydot(1) = y(2); % f '
ydot(2) = y(3); % f ''
ydot(3) = -y(1) * y(3) + Msq * y(2); % f''' = -y(1)*y(3) + 0.5*y(2 )
ydot(4) = y(5); % theta '
ydot(5) = -Pr * (Nb * y(7) * y(5) + Nt * y(5) * y(5)); % theta ''
ydot(6) = y(7); % psi '
ydot(7) = - (Nt/Nb) * ydot(5) - (Le/Nb) * y(1); % psi ''
end
Put the code from above in a file, name it main.m, load it into MATLAB and run it.

  0 件のコメント

サインイン to comment.



Translated by