Hi all!
I'm working on a class to run a two compartment system for fluids. I'm trying to solve an ODE with a Jacobian. When I was first running it, my main problem is there were too many outputs. When I tried switching the RHS to a column operator there is a problem with the column operator. I attached snips of the code below: Thanks for any help!
Too many outputs:function Num_Trajectory = get.Numerical(obj)
A = [-obj.ke1+obj.k1 obj.k2*(obj.V2/obj.V1); obj.k1*(obj.V1/obj.V2) -obj.k2] % This is the jacobian of the ODE.
Jacobian = @(t,x)A; % Rewrite the jacobian as a function.
RHS = @(t,x)A*x; % This is the RHS of the ODE.
ode_options = odeset('Jacobian',Jacobian); % Load the jacobian into the ODE options.
[~,Num_Trajectory] = ode23s(RHS,obj.tarray,obj.C01,ode_options); % Solve ODE for trajectory.
end
Colon Operator:
function Num_Trajectory = get.Numerical(obj)
% In this function, we set up the NUMERICAL trajectory
A = [-obj.ke1+obj.k1 obj.k2*(obj.V2/obj.V1); obj.k1*(obj.V1/obj.V2) -obj.k2] % This is the jacobian of the ODE.
Jacobian = @(t,x)A; % Rewrite the jacobian as a function.
RHS = @(t,x)A*x; % This is the RHS of the ODE.
ode_options = odeset('Jacobian',Jacobian); % Load the jacobian into the ODE options.
[tarray,Num_Trajectory] = ode45(RHS(:),obj.tarray,obj.C01,ode_options); % Solve ODE for trajectory.
end