Error in ode45 (line 115) and odearguments (line 90)

조회 수: 3 (최근 30일)
jhdueon
jhdueon 2021년 10월 19일
댓글: Star Strider 2021년 10월 19일
Hello all together,
I have written the following code, but it keeping getting the same error:
function dydt=overwork(t,y,re,rr,oe,or,be,br,ae,ar)
dydt=zeros(2,1);
dydt(1)=y(1)*(1-y(1))*(y(2)*(oe*re-be*rr)-ae*re);
dydt(2)=y(2)*(1-y(2))*((y(1)*(or*rr-br*re)-ar*rr);
end
clc;
clear;
re=5;
rr=5;
oe=0.7;
or=0.7;
be=0.2;
br=0.2;
ae=0.4;
ar=0.2;
figure(1)
[t,y]=ode45(@(t,y) overwork(t,y,re,rr,oe,or,be,br,ae,ar),[0,20],[0.1,0.5]);
plot(y(:,1),y(:,2),'rh-','linewidth',1,'markersize',5,'markerfacecolor','r','markerindices');
grid on
hold on
xlabel('$x$','interpreter','latex','Rotation',0);
ylabel('$y$','interpreter','latex','Rotation',360);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in overwork2 (line 12)
[t,y]=ode45(@(t,y) overwork(t,y,re,rr,oe,or,be,br,ae,ar),[0,20],[0.1,0.5]);
Can somebody help me?
Thanks in advance and best regards to you all.

채택된 답변

Star Strider
Star Strider 2021년 10월 19일
There were two errors.
First:
dydt(2)=y(2)*(1-y(2))*((y(1)*(or*rr-br*re)-ar*rr);
↑ ← EXTRA UNMATCHED PARENTHESIS
Second:
In the plot call, 'markerindices' has a name although no associated values, throwing an error. (I deleted it.)
re=5;
rr=5;
oe=0.7;
or=0.7;
be=0.2;
br=0.2;
ae=0.4;
ar=0.2;
figure(1)
[t,y]=ode45(@(t,y) overwork(t,y,re,rr,oe,or,be,br,ae,ar),[0,20],[0.1,0.5]);
plot(y(:,1),y(:,2),'r-','linewidth',1,'markersize',5,'markerfacecolor','r');
grid on
hold on
xlabel('$x$','interpreter','latex','Rotation',0);
ylabel('$y$','interpreter','latex','Rotation',360);
function dydt=overwork(t,y,re,rr,oe,or,be,br,ae,ar)
dydt=zeros(2,1);
dydt(1)=y(1)*(1-y(1))*(y(2)*(oe*re-be*rr)-ae*re);
dydt(2)=y(2)*(1-y(2))*(y(1)*(or*rr-br*re)-ar*rr);
end
With those corrections, it works!
.
  댓글 수: 2
jhdueon
jhdueon 2021년 10월 19일
the "EXTRA UNMATCHED PARENTHESIS" really matters!! Thanks!!
Star Strider
Star Strider 2021년 10월 19일
As always, my pleasure!
.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Historical Contests에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by