Phase portrait for Complex ODE

3 views (last 30 days)
Sergio Manzetti
Sergio Manzetti on 23 Nov 2017
Edited: Jan on 23 Nov 2017
Hi, I am trying to use:
if true
% code
end
function pdecaller()
options = odeset('OutputFcn',@odephas2);
for i=-4:4
for j= -4:4
[t,y] = ode45(@vdp1,[0 20],[i;j],options); hold on;
end
end
end
%c
function dydt = vdp1(t,y)
dydt=[ -i*(5.34E-12.*2.*2.033E-22)/((3.66E-5)^2).*y(1)-5.79E-68; y(2)];;
end
to plot a complex phase portrait. It gives however the result:
>> phaseportrait_caller Error using odephas2 (line 67) Error updating the ODEPHAS2 window. Solution data may have been corrupted. Argument X cannot be complex.
Error in ode45 (line 435) stop = feval(outputFcn,tout_new,yout_new(outputs,:),'',outputArgs{:});
Error in phaseportrait_caller (line 5) [t,y] = ode45(@vdp1,[0 20],[i;j],options); hold on;
Can anyone think of an alternative?
Thanks
  2 Comments
Jan
Jan on 23 Nov 2017
What is the purpose of "hold on" here? It seems like the error occurs in odepahs2, but you did not post the corresponding code.
Your initial values have the magnitude of 1. The formula for the 1st component is (constants calculated already):
1i * 1.6208635671414494e-33 * y(1) - 5.79e-68
and the 2nd component is fixed. Then the 2nd component is independent from the 1st one and you can omit the repeated integrations. Note that the term "5.79e-68" will matter for i=0 only, because it is too tiny and the limited precision will round it away.
I'm not sure if the step size control of ODE45 handles the two magnitudes differing by a factor of 1e32 as you expect it. Maybe it is smarter to scale the inputs to be in the same magnitude.
Sergio Manzetti
Sergio Manzetti on 23 Nov 2017
Edited: Sergio Manzetti on 23 Nov 2017
I don't know if this is related to your point Jan, but this software plots linear flow of vectors when it should plot a spiral flow phase portrait.

Sign in to comment.

Accepted Answer

Birdman
Birdman on 23 Nov 2017
Run the attached m file in command line and a GUI will open. Then enter your differential equations and you can easily plot the phase portrait for your ode.
  15 Comments
Jan
Jan on 23 Nov 2017
Edited: Jan on 23 Nov 2017
@cvklpstunc: Finding a file in the internet, does not mean, that it is "public open" and that you can use it how ever you want. Especially when it is coming from the FileExchange, it is covered by the BSD license. You find the license file on the FileExchange page and in the downloaded ZIP file. Publishing the code without the license file is not allowed. Posting it in the forum means to publish it under CC BY-SA 3.0, which is not exactly the same as the BSD.
It is much more useful to post the link to FileExchange instead of the code: Then the readers in the forum get the current version of the code in a few years also and there is not trouble with the license at all.
Birdman
Birdman on 23 Nov 2017
@Jan: ok, i will be careful next time about it, thanks.

Sign in to comment.

More Answers (1)

Sergio Manzetti
Sergio Manzetti on 23 Nov 2017
thanks! I can only see arrows pointing in one direction
  1 Comment
Birdman
Birdman on 23 Nov 2017
If the answer is useful, please accept it. And delete this answer. If you want to reply, write it under my answer.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!