Do the ODE functions from MATLAB (i.e. ODE23, ODE24) handle complex numbers properly?
9 views (last 30 days)
Show older comments
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]);
Accepted Answer
MathWorks Support Team
on 26 Jul 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 Comments
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!