Solving differential equation with parameters takes forever

조회 수: 3 (최근 30일)
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?

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2020년 7월 8일
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
Bjorn Gustavsson
Bjorn Gustavsson 2020년 7월 8일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by