Error message "Error using EXIST, The first input to exist must be a string."

조회 수: 17 (최근 30일)
system of 1st order ODE for a series/parallel reaction system, A>D>U & A>U
function [xdot] = rates(t,x);
rate_AD = 0.06*x(1); rate_AU = (0.12*x(1)^0.5)/(1 + 0.2*x(3)); rate_DU = (0.25*x(2))/(1 + 1.5*x(2)*x(3));
xdot(1,:) = -(rate_AD + rate_AU);
xdot(2,:) = rate_AD - rate_DU ;
xdot(3,:) = - xdot(1) - xdot(2) ;
end.
i try to evauluate using ode45:
x0 = [2/300;0;0]; % Initial concentrations of components [mol/m^3]
tspan = [0 100] ; % Time domain [s]
[t,x] = ode45(rates,tspan,x0);
what am i missing?

채택된 답변

Rik
Rik 2017년 4월 24일
The first input to ode45 must be a function handle. That means that you should have entered this:
[t,x] = ode45(@rates,tspan,x0);
When in doubt, RTFM (or in this case the documentation).
  댓글 수: 3
Rik
Rik 2017년 4월 24일
Good that you figured it out. Reading documentation of functions you are using often helps a lot when you get errors.
PS If you found my answer useful, please mark it as accepted answer. It will give us both reputation points and will make it easier for other people with the same question to find an answer.
Stephen23
Stephen23 2017년 4월 24일
편집: Stephen23 2017년 4월 24일
@Matthew Logan: using a function handle is the recommended (and better) way to specify the input, exactly as Rik Wisselink showed:
[t,x] = ode45(@rates,tspan,x0);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by