Trying to plot two equations with ezplot.

2 次查看(过去 30 天)
Hello:
I am trying to plot a pair of simultaneous equations to see at which points they intersect for a given interval 0 to 6pi. The first equation would be plotted in green and the second equation would be plotted in blue.
My code is as follows:
c=input('c');
syms p q
eqn1 =(p^2*q^2*(q^2+p^2)+c^2*(p^4+q^4-6*p^2*q^2)-3*c^4*(p^2-q^2)-4*c^6)*sin(p)*sinh(q)+2*p*q*(-p^2*q^2+3*c^2*(p^2-q^2)-7*c^4)*cos(p)*cosh(q)-p*q*(p^4+q^4+2*c^2*(q^2-p^2)+2*c^4)*cos(2*c)==0;
eqn2 = 2*c*p*(3*p^2*q^2-q^4-c^2*(p^2+q^2)+4*c^4)*cos(p)*sinh(q)+2*c*q*(p^4-3*q^2*p^2-c^2*(p^2+q^2)-4*c^2)*sin(p)*cosh(q)+p*q*((p^2+q^2)*(q^2-p^2+2*c^2))*sin(2*c)==0;
a = axes;
h = ezplot(eqn1);
h.LineColor = 'green';
hold on
grid on
g = ezplot(eqn2);
g.LineColor = 'blue';
L=sym(0:pi:6*pi);
a.PTick = double(L);
a.QTick = double(L);
M = arrayfun(@char, L, 'UniformOutput', false);
a.PTick = M;
a.QTick = M;
title('Plot of System of Nonlinear Equations')
legend('eqn1','eqn2', 'location', 'best')
% code
However, when I run the script, both of my equations come out in the same color: green. For example, when I choose for my input of c to be 1, my plot comes like this:
It seems in all other respects to be running as it should.
Any assistance is appreciated. Thank you in advance.
  2 个评论
Star Strider
Star Strider 2015-7-22
The colours plot correctly for me (in R2015a), but ‘PTick’ is throwing an error. (Neither MATLAB nor I have ever heard of it.)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by