Same result but without ode45

1 Ansicht (letzte 30 Tage)
Kebels3
Kebels3 am 4 Mär. 2021
Kommentiert: Rik am 4 Mär. 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);
plot(t,y)
legend({'Position', 'Speed'});
xlabel('Time [s]');
ylabel('Position [S] // Speed [v]');
But im stuck, can you guys help me?
  2 Kommentare
Marnix Moons
Marnix Moons am 4 Mär. 2021
Dear forum user,
If the school wants you to implement this without using ode45, you should suppose they will not be happy if you use the results that other Matlab users post here.
Rik
Rik am 4 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 4 Mär. 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.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by