Need a column vector from ode45, but I keep getting a struct

For some homework I'm trying to use ODE45 using a third-order chemical reaction equation.
k3 = 0.1;
tspan = 0:100;
C0 = 0.6;
dCadt = @(t,Ca) (-k3.*Ca.^3);
ode_solver = ode45(dCadt, tspan, C0); % ODE solver used in task 3, using the formula from Q1
this is the code I'm using, but I keep getting a struct and I can't extract any values from that. I would like to get a column vector, so I can calculate errors between different ODE solvers. Can anyone help me with this?

1 Comment

cell2mat(struct2cell(ode_solver)) also doesn't seem to work for some reason.

Sign in to comment.

 Accepted Answer

Read about structures.
k3 = 0.1;
tspan = 0:100;
C0 = 0.6;
dCadt = @(t,Ca) (-k3.*Ca.^3);
ode_solver = ode45(dCadt, tspan, C0); % ODE solver used in task 3, using the formula from Q1
plot(ode_solver.x,ode_solver.y)

More Answers (0)

Products

Release

R2021b

Tags

Asked:

on 5 Jan 2022

Commented:

on 5 Jan 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!