Solving differential equation with parameters takes forever
1 次查看(过去 30 天)
显示 更早的评论
I have 2 main equations
psi = 1
theta(0) = -pi/4
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/328556/image.png)
and
phi = 0.2
x(0) = -pi/2
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/328559/image.png)
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?
0 个评论
采纳的回答
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
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 Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!