Bernoulli differential equation moving electric car
Show older comments
Hello,
I am trying to plot this function in matlab dv/dt+K*v=-C*v^2 with K and C constants for this particular model.
I know it is a bernoulli equation but I don't know how to solve it exactly.
I am writing
f=@(t,v) -C*v^2-K*v;
[t,v]=ode23(f,[0,20],v0)
plot(t,v)
to evaluate the function between 0 and 20 seconds with an initial speed v0=30 m/s
Thank you
9 Comments
Star Strider
on 7 May 2020
C = ?;
K = ?;
Richard Escriva
on 7 May 2020
Ameer Hamza
on 7 May 2020
Your code seems correct, according to the ODE you posted. Are you getting unexpected results?
Star Strider
on 8 May 2020
The plot appears to be essentially a hyperbola.
Were you expecting something else?
Richard Escriva
on 8 May 2020
Star Strider
on 8 May 2020
So should it be:
f=@(t,v) -(C/m)*v^2-(K/m)*v;
instead?
Richard Escriva
on 10 May 2020
Edited: Ameer Hamza
on 10 May 2020
Ameer Hamza
on 10 May 2020
Yes, the code is correct according to the equation.
Richard Escriva
on 10 May 2020
Edited: darova
on 10 May 2020
Answers (0)
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!