Trying to plot two equations with ezplot.

조회 수: 5 (최근 30일)
Nick Barker
Nick Barker 2015년 7월 22일
댓글: Star Strider 2015년 7월 22일
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
Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 22일
What is a.PTick?
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