Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to plot(graph) cubic equation?

Subject: How to plot(graph) cubic equation?

From: swe lin

Date: 24 Aug, 2010 16:43:08

Message: 1 of 5

Please point me out how to plot the following equation:

( ( 5+ 6*x)/3 )^3 + ((2 - 3*x + 4*y)/2) ^2 =0;

Thank in advance!

Subject: How to plot(graph) cubic equation?

From: Wayne King

Date: 24 Aug, 2010 17:19:07

Message: 2 of 5

"swe lin " <pcgeekservice@gmail.com> wrote in message <i50sqr$gd6$1@fred.mathworks.com>...
> Please point me out how to plot the following equation:
>
> ( ( 5+ 6*x)/3 )^3 + ((2 - 3*x + 4*y)/2) ^2 =0;
>
> Thank in advance!

Hi, There are many ways to go about this. You can just plot the function as a surface and just visually see where f(x,y)=0

x = -10:.1:10;
y = -10:.1:10;
[xnew,ynew] = meshgrid(x,y);
 z = ( ( 5+ 6*xnew)/3 ).^3 + ((2 - 3*xnew + 4*ynew)/2).^2;
surf(x,y,z)
 shading interp
 view(-16,12)

You can do it as a 3d contour which makes it a bit more salient where f(x,y)=0

contour3(xnew,ynew,z);

or simply as a filled contour

contourf(xnew,ynew,z); xlabel('X'); ylabel('Y');

Wayne

Subject: How to plot(graph) cubic equation?

From: swe lin

Date: 24 Aug, 2010 18:35:25

Message: 3 of 5

"Wayne King" <wmkingty@gmail.com> wrote in message <i50uub$5ok$1@fred.mathworks.com>...
> "swe lin " <pcgeekservice@gmail.com> wrote in message <i50sqr$gd6$1@fred.mathworks.com>...
> > Please point me out how to plot the following equation:
> >
> > ( ( 5+ 6*x)/3 )^3 + ((2 - 3*x + 4*y)/2) ^2 =0;
> >
> > Thank in advance!
>
> Hi, There are many ways to go about this. You can just plot the function as a surface and just visually see where f(x,y)=0
>
> x = -10:.1:10;
> y = -10:.1:10;
> [xnew,ynew] = meshgrid(x,y);
> z = ( ( 5+ 6*xnew)/3 ).^3 + ((2 - 3*xnew + 4*ynew)/2).^2;
> surf(x,y,z)
> shading interp
> view(-16,12)
>
> You can do it as a 3d contour which makes it a bit more salient where f(x,y)=0
>
> contour3(xnew,ynew,z);
>
> or simply as a filled contour
>
> contourf(xnew,ynew,z); xlabel('X'); ylabel('Y');
>
> Wayne

Thank you so much

Subject: How to plot(graph) cubic equation?

From: Roger Stafford

Date: 24 Aug, 2010 20:28:07

Message: 4 of 5

"swe lin " <pcgeekservice@gmail.com> wrote in message <i50sqr$gd6$1@fred.mathworks.com>...
> Please point me out how to plot the following equation:
>
> ( ( 5+ 6*x)/3 )^3 + ((2 - 3*x + 4*y)/2) ^2 =0;
>
> Thank in advance!
- - - - - - - - - -
  Your equation is quadratic in y, so you can solve for y in terms of x and get two branches (solutions):

 y = (3*x-2)/4 + 1/2*sqrt(-((5+6*x)/3).^3);
 y = (3*x-2)/4 - 1/2*sqrt(-((5+6*x)/3).^3);

You can make plots of both of these functions together and they will give you the desired curve. It will have a sharp cusp in it where the two functions meet. Notice that you will get real solutions only for x <= -5/6.

Roger Stafford

Subject: How to plot(graph) cubic equation?

From: Loren Shure

Date: 25 Aug, 2010 13:41:24

Message: 5 of 5


"swe lin " <pcgeekservice@gmail.com> wrote in message
news:i50sqr$gd6$1@fred.mathworks.com...
> Please point me out how to plot the following equation:
>
> ( ( 5+ 6*x)/3 )^3 + ((2 - 3*x + 4*y)/2) ^2 =0;
>
> Thank in advance!

If you have the Symbolic Math Toolbox, you can do this:

syms x y
expr = ( ( 5+ 6*x)/3 )^3 + ((2 - 3*x + 4*y)/2) ^2
ezsurf(expr)


--
Loren
http://blogs.mathworks.com/loren/
http://matlabwiki.mathworks.com/MATLAB_FAQ

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us