I want to solve two coupled ODEs in matlab using ODE45, but get an error that says U"nable to perform assignment because the left and right sides have a different number of elements". I dont know really what the problem is here and have tried severad changes but did not fix it.
Code:
function dz = myode(v,z)
a = 0.4;
b = 0.001;
c = 0.001;
d = 0.9;
dz = zeros(2,1);
dz(1) = a*z(1)-b*z(2)*z(1);
dz(2) = c*z(1)*z(2)-diff(z(2));
end
I call it as:
[v z] = ode45(@myode,[0 40],[2 6])
Hope someone can help
1 Comment
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/595231-ode45-coupled-first-degree-odes#comment_1012711
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/595231-ode45-coupled-first-degree-odes#comment_1012711
Sign in to comment.