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

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

댓글을 달려면 로그인하십시오.

 채택된 답변

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)

추가 답변 (0개)

카테고리

제품

릴리스

R2021b

태그

질문:

2022년 1월 5일

댓글:

2022년 1월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by