Phase portrait for Complex ODE
3 views (last 30 days)
Show older comments
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
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.
Accepted Answer
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
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.
Please read and consider https://www.mathworks.com/matlabcentral/answers/322209-is-it-legal-to-publish-the-source-code-of-matlab-s-toolbox-functions.
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.
More Answers (1)
Sergio Manzetti
on 23 Nov 2017
1 Comment
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.
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!