I've been given following task and got stuck. Apparently I am returning a vector of length 4 instead of the 2 it should be.
The differential equation I am trying to plot is: dv/dt=v*(1-v)(v-alpha)-w+C and dw/dt=varepsilon(v-gamma*w)
function dydt = fun (v, alpha, w, C, gamma, varepsilon)
dydt = [v*(1-v)*(v-alpha)-w+C;varepsilon*(v-gamma*w)]
end
This is the Fitzhugh-Nagumo model (http://en.wikipedia.org/wiki/FitzHugh-Nagumo_model)
Now I want to solve this equation via ode45 (this is a prerequisite) in the following script:
tspan = [0, 6]; y0 = [1; 1];
alpha = 0.7;
gamma = 0.8;
varepsilon = 12.5;
C = 0.5;
ode = @(v,w) fun (v, alpha, w, C, gamma, varepsilon);
[v,w] = ode45(ode, tspan, y0);
plot(t,v(:,1),'r')
xlabel ('t')
ylabel('solution v & w')
title ('opdracht 1, name')
hold on
plot(t,w(:,1),'b')
shg
The goal is to plot v and w in function of t (time, defined by tspan). But I get the following error: Error using odearguments (line 92) @(V,W)OPDRACHT1FUNCTIEV(V,ALPHA,W,C,GAMMA,VAREPSILON) returns a vector of length 4, but the length of initial conditions vector is 2. The vector returned by @(V,W)OPDRACHT1FUNCTIEV(V,ALPHA,W,C,GAMMA,VAREPSILON) and the initial conditions vector must have the same number of elements.
Can anyone tell me where these 4 solutions come from whilst there only should be 2? The handle @(v,w) contains but two values, does this not suffice? Thanks in advance!