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
Best Answer