Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
i am getting an error. on putting values in a function. Here Y is average of all values of (dx)/(dt)
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Star Strider
il 15 Dic 2017
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 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!