Why are values in my loop filled with NaN?
이전 댓글 표시
Hello,
Can anyone tell why 'u' and 'v' inside my loop are all being filled with NaN? I cant figure out what I'm doing wrong. Thanks!
close all;
clear all;
a = 0;
b = 20;
nel = 200; % number of elements
h = (b-a)/nel; % step size
nv = nel+1;% number of vertices
x = a:h:b; % mesh
dt = 0.001; % time steps
tend = 20;
e=ones(nv, 1);
%Discretization of the Laplace operator
Delta=1/(h^2)*spdiags([e -2*e e], -1:1, nv, nv);
Delta(1,2) = 2/h^2;
Delta(end,end-1) = -2/h^2;
% parameters of the model
eps = 0.02;
alpha = 0.1;
% initial guess
u = 0.5 * (x < 3);
v = 0 * x;
counter = 1;
% explicit Euler scheme
for t=dt:dt:tend
u = u + dt/eps*(u .*(1-u).*(u-alpha) - v - ((Delta * u')'));
v = v + dt * (u - v);
end
figcure(1)
plot(x,u,x,v,'r');
legend('u','v')
title('Solution of the Fitz-Hugh-Nagumo system')
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 NaNs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!