How to solve this error while using ode15s.

조회 수: 1 (최근 30일)
bhargav mehar
bhargav mehar 2020년 11월 26일
댓글: bhargav mehar 2020년 11월 27일
function dx=man(t,x,V,VF,y,L,D,acond)
dx =((V+VF)*y-L*x-D*x)*1/acond;
end
%%prob settings
lb=[0 0 0 0 0 0 ];
ub= [100 120 1 100 110 20 ];
prob=@(t,x) man(t,x,V,VF,y,L,D,acond);---------main areas creating the error
%% parameters for differential evolution
np=10;
it=100;
cr=0.7;
F=0.8;
%% START of DE
f=NaN(np,1);
fu=NaN(np,1);
d=length(lb);
U=NaN(np,d);
p= repmat(lb,np,1)+(repmat((ub-lb),np,1).*rand(np,d));
for i=1:np
A=p(i,:);
V=A(1);
VF=A(2);
y=A(3);
L=A(4);
D=A(5);
acond=A(6);
[t X]=ode15s('prob',[0 75],0);-------main areas creating the error.
f(i)=X(100,1);
end

채택된 답변

Stephan
Stephan 2020년 11월 27일
%prob settings
lb=[0 0 0 0 0 0 ];
ub= [100 120 1 100 110 20 ];
% parameters for differential evolution
np=10;
it=100;
cr=0.7;
F=0.8;
% START of DE
f=NaN(np,1);
fu=NaN(np,1);
d=length(lb);
U=NaN(np,d);
p= repmat(lb,np,1)+(repmat((ub-lb),np,1).*rand(np,d));
for i=1:np
A=p(i,:);
V=A(1);
VF=A(2);
y=A(3);
L=A(4);
D=A(5);
acond=A(6);
[t, X]=ode15s(@(t,x)man(t,x,V,VF,y,L,D,acond),[0 75],0);
f(i)=X(size(t,1),1);
end
function dx=man(~,x,V,VF,y,L,D,acond)
dx =((V+VF)*y-L*x-D*x)*1/acond;
end
  댓글 수: 3
Stephan
Stephan 2020년 11월 27일
calling the function by passing extra parameters works this way:
[t, X]=ode15s(@(t,x)man(t,x,V,VF,y,L,D,acond),[0 75],0);
instead of:
prob=@(t,x) man(t,x,V,VF,y,L,D,acond);
.
.
.
[t X]=ode15s('prob',[0 75],0);
And inside the loop:
f(i)=X(size(t,1),1);
instead of
f(i)=X(100,1);
bhargav mehar
bhargav mehar 2020년 11월 27일
okay thank you so much

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

추가 답변 (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