How to solve this error while using ode15s.

1 Ansicht (letzte 30 Tage)
bhargav mehar
bhargav mehar am 26 Nov. 2020
Kommentiert: bhargav mehar am 27 Nov. 2020
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

Akzeptierte Antwort

Stephan
Stephan am 27 Nov. 2020
%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 Kommentare
Stephan
Stephan am 27 Nov. 2020
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 am 27 Nov. 2020
okay thank you so much

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by