MATLAB Answers

Same result but without ode45

38 views (last 30 days)
Kebels3 on 4 Mar 2021
Commented: Rik on 4 Mar 2021
Hi guys,
for a school test i need to rewrite this code, but whitout the function ode45
F = @(t, x) [x(2); -0.1/50*x(2) - 2*x(1)]
T = 0:0.001:10; S = [0.5 0];
[t, y] = ode45(F, T, S);
legend({'Position', 'Speed'});
xlabel('Time [s]');
ylabel('Position [S] // Speed [v]');
But im stuck, can you guys help me?
Rik on 4 Mar 2021
You can find guidelines for posting homework on this forum here. If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks). If your main issue is with understanding the underlying concept, you may consider re-reading the material you teacher provided and ask them for further clarification.

Sign in to comment.

Answers (1)

Jan on 4 Mar 2021
ODE45 is a stepsize controlled Dormand Prince Integrator with local extrapolation.
If you want to get exactly the same results, you find the instructions here:
  • The MATLAB ODE Suite, L. F. Shampine and M. W. Reichelt, SIAM Journal on Scientific Computing, 18-1, 1997.
  • Mark W. Reichelt and Lawrence F. Shampine, 6-14-94
I have written such an Dormand Prince method by my own also as homework in the university. It is possible to do this in 2 or 3 hours. You find many published codes of others also, e.g. in the FileExchange.
If you are trying this by your own, please post your code and explain, what "I'm stuck means". Based on the given information it is not possible to suggest a solution of your porblem.


Community Treasure Hunt

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

Start Hunting!