Solving an ODE for a Complex Variable in Polar Coordinates
Mostrar comentarios más antiguos
I want to solve an ODE where the variable of interest is a complex number in terms of polar coordinates,
. I have been using the example here where they have chosen
. I roughly know what the dynamics of the system should look like (it is a well-known reduction of the Kuramoto model) and am almost certain that it should not have features that cause ode45() to have any problems. However, the systems seems to blow up. I believe it is because of how I have set up definitions or returned values in the Second Function File, but I am not sure. Does anyone have any suggestions? Thanks!
Second Function File and Call:
% Set up ICs and t, then solve
zv0 = [0.8; 3];
tspan = [0 100];
[t, zv] = ode45(@imaginaryODE, tspan, zv0);
% Plot
plot(t,zv(:,1))
function fv = imaginaryODE(t, zv)
% Construct z from argument and angle
z = abs(zv(1)).*exp(1i.*angle(zv(2)));
% Evaluate for the function defined in complexf.m
zp = complexf(t, z);
% Return argument and angle
fv = [abs(zp); angle(zp)];
end
First Function File:
function f = complexf(t, z)
% Constants
omega0 = 2.*pi/24;
gamma = 1/100;
k = 1;
% Function
f = (1i.*omega0 - gamma).*z + (k/2).*(z - (z^2).*conj(z));
end
3 comentarios
darova
el 18 de Mzo. de 2020
Please attach original eqautions
Cameron3332
el 18 de Mzo. de 2020
darova
el 18 de Mzo. de 2020
You code looks OK. I changed this
tspan = [0 2.45];
result

Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


