Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

3 ビュー (過去 30 日間)
Sam17
Sam17 2017 年 12 月 15 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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);

回答 (1 件)

Star Strider
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.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by