Input values for ode-solver

9 views (last 30 days)
mattzoe
mattzoe on 18 Jun 2019
Commented: Walter Roberson on 18 Jun 2019
Hello everyone, I'm trying to solve an equation with the ode45-solver.
My problem is, that I don't know how to import the values from the variables Theta_D, Theta_p_D and Q_E_D into the function script. Those variables are calculated in the script and they are row-vectors. The calculation of those variables is complex and is omitted here
My function is:
function sdot = DGL_Getriebe(t,s)
sdot = [s(2);
(Q_E_D - 0.5 * Theta_p_D * s(2)^2) / Theta_D];
end
And my script is:
Theta_D = cell2mat(Theta);
Theta_p_D = cell2mat(Theta_p);
Q_E_D = cell2mat(Q_E);
t_span = [0 10];
q0 = [0 0];
[t, state_value] = ode45(@(t,s) DGL_Getriebe(q,s), t_span, q0);
q_an = state_value(:,1);
q_dot = state_value(:,2);
% Plots
Best regards!

Answers (0)

Community Treasure Hunt

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

Start Hunting!