Please help me with the error

1 次查看(过去 30 天)
Sam17
Sam17 2017-12-15
clear all;
clc;
N=20; % number of particles.
K=0.5; % Coupling strength.
b=3;
r=0.006;
x0=-1.67;
I=2.8
initial_value= randn(N,1); %initial matrix
F=@(t,x)[x(2)-(x(1).^3)+b.*(x(1).^2)-x(3)+I+K.*(((1/N)*(mean(x(1))))-x(1));1-(5.*(x(1)^2))-x(2);r*[4*(x(1)-x(0))-x(3)]]
[t,x]=ode45(F,[0 100],initial_value);
plot(t,sin(x));
title ('System of equations that represent a coupled neuronal system with different values of N')
grid on;
Error:
I =
2.8000
F =
@(t,x)[x(2)-(x(1).^3)+b.*(x(1).^2)-x(3)+I+K.*(((1/N)*(mean(x(1))))-x(1));1-(5.*(x(1)^2))-x(2);r*[4*(x(1)-x(0))-x(3)]]
Subscript indices must either be real positive integers or logicals.
Error in @(t,x)[x(2)-(x(1).^3)+b.*(x(1).^2)-x(3)+I+K.*(((1/N)*(mean(x(1))))-x(1));1-(5.*(x(1)^2))-x(2);r*[4*(x(1)-x(0))-x(3)]]
Error in odearguments (line 87) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 113) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in nov20_project (line 11) [t,x]=ode45(F,[0 100],initial_value);
>>

回答(1 个)

Walter Roberson
Walter Roberson 2017-12-15
You try to use x(0) which would try to index x at the 0'th position. Indices start at 1 in MATLAB.

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by