Info
此问题已关闭。 请重新打开它进行编辑或回答。
i am getting an error. on putting values in a function. Here Y is average of all values of (dx)/(dt)
2 次查看(过去 30 天)
显示 更早的评论
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.*(Y-x(1));1-5.*(x(1).^2)-x(2);r.*(4.*(x(1)-x(0))-x(3))]
xi=x(:,1);
Y=(1/N).*(mean(xi));
[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;
My error is:
Undefined variable x.
Error in nov20_project (line 11) xi=x(:,1);
0 个评论
回答(1 个)
Star Strider
2017-12-15
First, there is no 0 subscript in MATLAB, since MATLAB subscripts are integers greater than 0:
F=@(t,x)[x(2)-(x(1).^3)+b.*(x(1).^2)-x(3)+I+K.*(Y-x(1));1-5.*(x(1).^2)-x(2);r.*(4.*(x(1)-x(0))-x(3))];
↑
Another problem is that ‘Y’ is undefined before you call ‘F’ (at least in the code you posted), so nothing works.
The variable ‘x’ does not exist in your code until after you integrate your differential equation ‘F’, and the ‘x(0)’ element prevents that.
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!