Hello, I have problem with odeToVectorField in ODE second order system of equations.
3 commentaires
Réponse acceptée
0 commentaires
Plus de réponses (2)
- Try linearizing the equations around an operating point using small angle approximations. This would eliminate the trig terms and result in a linear system that odeToVectorField can handle.
- Use an alternate ODE solver in MATLAB that supports nonlinear systems, like ode45:
0 commentaires
6 commentaires
sym() of a floating point number can return multiples of π and square roots when the default conversion is used. The default conversion also approximates... so for example a floating point number sufficiently close to 1/3 will be converted to 1/3, not just the single double precision number that most closely represents 1/3. π ± about 999 eps is converted to π
But once you have converted to rational or sqrt or pi, the symbolic engine sticks with the representation and calculates with it until you have a double() or vpa() or vpaintegral(), or you have a relational operation in a context that forces a decision to be made. "if A<B" can be difficult to answer when A and B are symbolic formula. The engine cannot rely on being able to come up with mathematical proofs so sometimes it has to resort to numeric evaluation. But it holds off until then.
For example sum(sin(sym(linspace(0,pi))) will give a mostly unevaluated sum of hundreds of sin terms: it does not approximate the sin of rationals.
Now if you construct a symbolic floating-point number then the engine will create approximations as it goes. for example sym('1.23') or str2sym('1.23') or sym() of a floating point number with particular options to the call. Once you are working with symbolic floating-point including if you vpa() then you can run into the same kind of issues as you can with double precision
Voir également
Catégories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!