ode arguments error in function
이전 댓글 표시
I am trying to solve 2 differential equations wrt W, but i am getting this error.
A0 = [0 1];
Wspan = [0 100];
[W, A] = ode45(@ODEfun, Wspan, A0);
plot(z, fb(:,1));
function dYfuncvecdW = ODEfun(W, Yfuncvec)
X = Yfuncvec(1);
y = Yfuncvec(2);
k = 6;
Cao = 0.2;
yao = 1/3;
Fao = 2;
Pao = 10;
epsilon = yao*(1-2-1);
ThetaB = 2;
alpha = 0.02;
Ca = Cao*(1-X)/(1+(epsilon*X))*y;
Cb = Cao*(ThetaB-(2*X))/(1+(epsilon*X))*y;
ra = -k*Ca*Cb^2;
dXdW = -(ra/Fao);
dydW = -alpha*(1+(epsilon*X))/2/y;
dYfuncvecdW = [dXdW dydW];
end
답변 (1개)
Alan Stevens
2020년 10월 21일
For the last line in your function you need
dYfuncvecdW = [dXdW; dydW];
Notice the semicolon after dXdW
Also your plot command needs to be
plot(W, A(:,1));
댓글 수: 2
Elliot Alderson
2020년 10월 21일
Alan Stevens
2020년 10월 21일
You don't! Calculate CA outside of the function and then plot it against W. Where you have X inside the function use A(:,1) outside the function.
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!