problem with ode45 solving

1 view (last 30 days)
Juan Hurtado
Juan Hurtado on 28 Apr 2021
Commented: Star Strider on 3 May 2021
Hello, I'm trying to solve the following system of differential equations but I'm not getting the right answer
ode1 = diff(x) == v;
ode2 = diff(v) == u;
t_interval = [0,10]
x0 = 0
v0 = 0
u = 1
because of how things are set up I can wrap my head on creating the function. Any help would be appreciate it.

Accepted Answer

Star Strider
Star Strider on 28 Apr 2021
Assuming both functions are functions of time —
syms x(t) v(t)
u = sym(1);
ode1 = diff(x) == v
ode1(t) = 
ode2 = diff(v) == u
ode2(t) = 
[x(t),v(t)] = dsolve(ode1,ode2, x(0)==0, v(0)==0)
x(t) = 
t
v(t) = 
figure
fplot(x, [0 10])
hold on
fplot(v, [0 1])
hold off
grid
xlabel('t')
legend('x(t)','v(t)')
.
  20 Comments
Juan Hurtado
Juan Hurtado on 3 May 2021
Perfect! Well I that solves all my doubts. I reall appreciate all your help.
Thank you so much!
Star Strider
Star Strider on 3 May 2021
As always, my pleasure!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!