function dxdt = odefcn(t,x,a,b,c,u)dxdt = zeros(2,1);dxdt(1) = a*x(1)+2*x(2)+u;dxdt(2) = c*x(1)+ b*x(2)-2*u;endclc;clear all; close all;a=-1; b=-2; c=0; u=3;tspan = [0 20];[t,x] = ode45(@odefcn,tspan,[0 0]);figure(1)plot(t,x(:,1),'r',t,x(:,2),'b')
i am getting an error (attached screenshot)
while i am not getting error when i am using
a=-5; b=-3; c=1; u=3;tspan = [0 20];[t,x] = ode45(@(t,x) odefcn(t,x,a,b,c,u),tspan,[0 0]);figure(2)plot(t,x(:,1),'r',t,x(:,2),'b')
can anyone please explain
Best Answer