Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

i am getting an error. on putting values in a function. Here Y is average of all values of (dx)/(dt)

3 vues (au cours des 30 derniers jours)
Sam17
Sam17 le 15 Déc 2017
Clôturé : MATLAB Answer Bot le 20 Août 2021
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);

Réponses (1)

Star Strider
Star Strider le 15 Déc 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.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by