How to solve this error while using ode15s.

1 visualización (últimos 30 días)
bhargav mehar
bhargav mehar el 26 de Nov. de 2020
Comentada: bhargav mehar el 27 de Nov. de 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

Respuesta aceptada

Stephan
Stephan el 27 de Nov. de 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 comentarios
Stephan
Stephan el 27 de Nov. de 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 el 27 de Nov. de 2020
okay thank you so much

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by