Solving differential equation with parameters takes forever

6 views (last 30 days)
I have 2 main equations
psi = 1
theta(0) = -pi/4
and
phi = 0.2
x(0) = -pi/2
I defined x z theta(t) and x(t) symbolically, and tried to solve with dsolve using symbolic toolbox. When I solve the first equation, I get two answers parametrized by z1 and z18, respectively. When I try to plug in one of the values into the second equation, it takes forever to solve, and never return an answer so I end up pausing it. Is there a faster and simpler way to solve this?

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 8 Jul 2020
If both x and theta varies with t you cannot solve one first and the other separately later, you should treat them as a system of coupled ODEs. Since both equations are nonlinear and they don't have simple analytical solutions you might get further faster with numerical integration of the system. Have a look at ode45 and the numerical ode-examples.
HTH
  3 Comments
Bjorn Gustavsson
Bjorn Gustavsson on 8 Jul 2020
Well, you can proceed in so many different ways with the output, this is what I typically start off with:
First I plot the individual components as a function of time:
for i1 = 1:3
subplot(3,1,i1)
plot(t,yout(:,i1))
end
% or all in one panel...
That should give you a first view of what the solution looks like. Then I'd try what you did, possibly it is also worthwhile to use the comet and comet3 functions to see how the solution moves in your 2 and three components. For this it is preferable to get the solution at equally spaced steps in time. If I model a physical system with some constants of motion (momentum, energy etc) I'd also have a look at how those properties behave. But as you see, from here we could look at this in so many different ways that you will have to try those that seem to lead you to what you want out - it is just to try everything you can think of that is interesting and see what sticks.

Sign in to comment.

More Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!