Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Is there any way I can ensure that the numbers generated in ode45 are positive?

1 visualización (últimos 30 días)
Here is my code. Many numbers generated in the solution are negative and there are a lot of NaNs too.
%setting up the values of constants
N=1000; %number of systems
%m=0.3*ones(N,1)
%S=0.7;%coupling streangth
tspan=linspace(0,10000,10000)';%time steps
%solving the equation
ystart=zeros(N,1);
for i=1:N
ystart(i)=unifrnd(0,1);%Initial conditions; (9 by 1) column vector
%indicating that each oscillator starts with
%random initil voltage between 0 and 1
end
%options=odeset('NonNegative',1);
[t,y]=ode45(@CLIF,tspan,ystart);%options);
%Plotting
%rescale(y(11,:))
plot(y(5,:),'.')
%axis([1 11 0 1])
xlabel('ith oscillator')
ylabel('voltage')
title('Coupled LIF')
%Defining the system of equations
function dydt=CLIF(t,y,m,N,S)
N=1000;
m=0.3;
S=15;
dydt=zeros(N,1);
for i=1:N
if i<N
dydt(i)=-y(i)+m+(S).*((y(i)-y(i+1)));
else
break
end
end
end
  13 comentarios
Jan
Jan el 24 de Oct. de 2018
You need y(i+1) to construct the N'th value. Does y has N+1 elements? If so, use N instead of N-1.

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by