Input arguments error on line 2

조회 수: 1 (최근 30일)
Rishabh Arora
Rishabh Arora 2020년 10월 21일
편집: Rishabh Arora 2020년 10월 21일
I am getting input arguments error on line 2 of the function
  댓글 수: 3
Ameer Hamza
Ameer Hamza 2020년 10월 21일
Why are you calling ode45 inside the ODEfun and using ODEfun as a function handle. This will not work and cause infinite recursion.
drummer
drummer 2020년 10월 21일
where is W being used?

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

채택된 답변

Stephan
Stephan 2020년 10월 21일
편집: Stephan 2020년 10월 21일
Divide your code into a function for your ode and the part for solving and plottting the results:
y0 = 0; % --> change to 1 for example to get a "non boring" solution
Wspan = [0 100];
[z, fb] = ode45(@ODEfun, Wspan, y0);
plot(z, fb(:,1));
function dYfuncvecdW = ODEfun(~, Yfuncvec)
X = Yfuncvec(1);
k = 6;
Cao = 0.2;
yao = 1/3;
Fao = 2;
% Pao = 10; --> Value is not used
epsilon = yao*(1-2-1);
ThetaB = 2;
% alpha = 0.02; --> Value is not used
Ca = Cao*(1-X)/(1+(epsilon*X));
Cb = Cao*(ThetaB-(2*X))/(1+(epsilon*X));
ra = -k*Ca*Cb^2;
dXdW = -(ra/Fao);
dYfuncvecdW = dXdW;
end

추가 답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 10월 21일
How are you running this function? You need to pass input aguments to get an output
out = ODEfun(0, 1)

카테고리

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