Do the ODE functions from MATLAB (i.e. ODE23, ODE24) handle complex numbers properly?
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
For example, I want to integrate the equation dy/dt = sqrt(t) + y for 't' from -10 to 10 and for initial 'y' values of 1 and 2.
To do this, I would use:
]
[t,y] = ode45(@(t,y) sqrt(t)+y,-10:10,[1 2]);
Réponse acceptée
MathWorks Support Team
le 26 Juil 2010
The ODE solvers in MATLAB 5 (R12) and later releases properly handle complex valued systems.
When writing code, keep in mind the following:
The ' operator implements produces the conjugate transpose, while the .' operator performs a non-conjugate transpose. Improperly using one when you want the other will result in unexpected solutions.
For example:
M = rand(2)+rand(2)*i
M =
0.4451 + 0.8462i 0.4660 + 0.2026i
0.9318 + 0.5252i 0.4186 + 0.6721i
M.'
ans =
0.4451 + 0.8462i 0.9318 + 0.5252i
0.4660 + 0.2026i 0.4186 + 0.6721i
M'
ans =
0.4451 - 0.8462i 0.9318 - 0.5252i
0.4660 - 0.2026i 0.4186 - 0.6721i
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!