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:
Matlab Graph Plotting

Subject: Matlab Graph Plotting

From: Christopher McNamee

Date: 15 Dec, 2009 15:22:03

Message: 1 of 9

I'm new to Matlab and cant figure out how to plot the graph x.^2+y.^2=36. Would appreciate any help. Thanks In advance.

Subject: Matlab Graph Plotting

From: dpb

Date: 15 Dec, 2009 15:41:55

Message: 2 of 9

Christopher McNamee wrote:
> I'm new to Matlab and cant figure out how to plot the graph
> x.^2+y.^2=36. Would appreciate any help. Thanks In advance.

doc surf

--

Subject: Matlab Graph Plotting

From: Sebastian Gatzka

Date: 15 Dec, 2009 15:45:20

Message: 3 of 9

"Christopher McNamee" <chrisy_mac88@hotmail.com> wrote in message <hg89iq$1j7$1@fred.mathworks.com>...
> I'm new to Matlab and cant figure out how to plot the graph x.^2+y.^2=36. Would appreciate any help. Thanks In advance.

1) Define your x and y interval (from 1 to 10 with stepsize 1 in this example)

>> x = [0:1:10]
>> y = [0:1:10]

2) For a 3D-plot you will have to create a mesh-array appropriate for 3D plotting tools out of your x and y data:

>> [X,Y] = meshgrid(x,y)

Note I have used capital letters for the new array!

3) Now you can define your Z-array which is constructed from the meshgrid array and is representing the function you want to plot:

>> Z = X.^2 + Y.^2 - 36

4) Finally you can plot your funktion using

>> surf(X,Y,Z)

Have a look: http://img97.imageshack.us/img97/3775/plot.jpg

There there are more options to do 3D plotting but I think this one is rather quick.

Subject: Matlab Graph Plotting

From: Christopher McNamee

Date: 15 Dec, 2009 15:58:01

Message: 4 of 9

Thanks for all the help, all I need is a 2D graph so how could i go about doing that?
Many Thanks Chris

 "Sebastian Gatzka" <sebastian.gatzka.NOSPAM@stud.tu-darmstadt.de> wrote in message <hg8aug$28o$1@fred.mathworks.com>...
> "Christopher McNamee" <chrisy_mac88@hotmail.com> wrote in message <hg89iq$1j7$1@fred.mathworks.com>...
> > I'm new to Matlab and cant figure out how to plot the graph x.^2+y.^2=36. Would appreciate any help. Thanks In advance.
>
> 1) Define your x and y interval (from 1 to 10 with stepsize 1 in this example)
>
> >> x = [0:1:10]
> >> y = [0:1:10]
>
> 2) For a 3D-plot you will have to create a mesh-array appropriate for 3D plotting tools out of your x and y data:
>
> >> [X,Y] = meshgrid(x,y)
>
> Note I have used capital letters for the new array!
>
> 3) Now you can define your Z-array which is constructed from the meshgrid array and is representing the function you want to plot:
>
> >> Z = X.^2 + Y.^2 - 36
>
> 4) Finally you can plot your funktion using
>
> >> surf(X,Y,Z)
>
> Have a look: http://img97.imageshack.us/img97/3775/plot.jpg
>
> There there are more options to do 3D plotting but I think this one is rather quick.

Subject: Matlab Graph Plotting

From: Loren Shure

Date: 15 Dec, 2009 16:37:45

Message: 5 of 9

In article <hg89iq$1j7$1@fred.mathworks.com>, chrisy_mac88@hotmail.com
says...
> I'm new to Matlab and cant figure out how to plot the graph x.^2+y.^2=36. Would appreciate any help. Thanks In advance.
>

Try rewriting the equation and use ezplot perhaps.

ezplot('x.^2+y.^2-36')
axis equal

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

Subject: Matlab Graph Plotting

From: dpb

Date: 15 Dec, 2009 17:42:54

Message: 6 of 9

Christopher McNamee wrote:
> Thanks for all the help, all I need is a 2D graph so how could i go about doing that?
...
Not sure what the definition of a 2D graph would be...

--

Subject: Matlab Graph Plotting

From: Sebastian Gatzka

Date: 15 Dec, 2009 21:32:05

Message: 7 of 9

"Christopher McNamee" <chrisy_mac88@hotmail.com> wrote in message <hg8bm9$l7r$1@fred.mathworks.com>...
> Thanks for all the help, all I need is a 2D graph so how could i go about doing that?
> Many Thanks Chris

What do you actually mean with "2D graph"?

Subject: Matlab Graph Plotting

From: Christopher McNamee

Date: 15 Dec, 2009 23:05:04

Message: 8 of 9

As in only in terms of x and y and not using z xo-ordinates. I got it workin now anyways so thanks for all your help.

 "Sebastian Gatzka" <sebastian.gatzka.NOSPAM@stud.tu-darmstadt.de> wrote in message <hg8v8l$b58$1@fred.mathworks.com>...
> "Christopher McNamee" <chrisy_mac88@hotmail.com> wrote in message <hg8bm9$l7r$1@fred.mathworks.com>...
> > Thanks for all the help, all I need is a 2D graph so how could i go about doing that?
> > Many Thanks Chris
>
> What do you actually mean with "2D graph"?

Subject: Matlab Graph Plotting

From: dpb

Date: 16 Dec, 2009 01:24:42

Message: 9 of 9

Christopher McNamee wrote:
> As in only in terms of x and y and not using z xo-ordinates. I got it
> workin now anyways so thanks for all your help.
...

Well, how about showing us, then..???

(BTW, please don't top-post--following hard conversation makes....)

--

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