why this equation is not ploting
2 views (last 30 days)
Show older comments
Tstart = 100;
Tend = 1000.0;
Nt = 2000;
dT = (Tend-Tstart)/Nt;
X0 = 0.3;
Y0 = 0;
Z0 = 0;
N = 20;
k1=1;
k2=2.52;
k3=1;
k4=5;
I=1.5;
s=4;
xr=-1.6;
r=0.01;
T = zeros(Nt+1,1);
X = zeros(Nt+1,1);
Y = zeros(Nt+1,1);
Z = zeros(Nt+1,1);
a = zeros(N+1,1);
b = zeros(N+1,1);
c = zeros(N+1,1);
T(1) = 0.0;
X(1) = X0;
Y(1) = Y0;
Z(1) = Z0;
for j = 2:Nt+1
a(1) = X(j-1);
b(1) = Y(j-1);
c(1) = Z(j-1);
for k = 1:N
a(k+1)=(b(k)-k1*a(k).^3+k2*a(k).^2-c(k)+I)/(k+1);
b(k+1)=(k3-k4*a(k).^2-b(k))/(k+1);
c(k+1)=r*(s*(a(k)-xr)-c(k))/(k+1);
end
x = a(1);
y = b(1);
z = c(1);
for k = 2:N+1
x = x + a(k)*dT^(k-1);
y = y + b(k)*dT^(k-1);
z = z + c(k)*dT^(k-1);
end
T(j) = T(j-1) + dT;
X(j) = x;
Y(j) = y;
Z(j) = z;
end
plot(T,X)
It's not showing the plot! How do I resolve this?
2 Comments
Answers (1)
Sam Chak
on 1 Apr 2022
Edited: Walter Roberson
on 1 Apr 2022
Hi @shiv gaur
Simulating the Hindmarsh–Rose model requires solving the differential equations using some numerical ode solvers. You can change the parameters in the code below for your study. If you find my Answer is helpful, please vote and Accept.
function Hindmarsh_Rose
close all
clc
tspan = [0 1000]; % time span of simulation
y0 = [-1.5 -10 2]; % initial values
[t, y] = ode45(@(t, y) odefcn(t, y), tspan, y0);
plot(t, y(:,1), 'linewidth', 1.5)
grid on
xlabel('Time, t [sec]')
ylabel('x(t)')
title('Hindmarsh–Rose Neuronal Bursting Model')
end
function dydt = odefcn(t, y) % Ordinary Differential Equations
dydt = zeros(3,1);
a = 1;
b = 3;
c = 1;
d = 5;
I = 2;
r = 0.0021;
s = 4;
xR = -8/5;
dydt(1) = y(2) - a*y(1)^3 + b*y(1)^2 - y(3) + I;
dydt(2) = c - d*y(1)^2 - y(2);
dydt(3) = r*(s*(y(1) - xR) - y(3));
end
Result:
17 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!