-1

I'm new to Matlab, and I was wondering how you might graph a two-variable function as a surface graph, like sin(x)/y^(log(x)). Say I create two ranges, x and y, both represented by the range -4:0.001:4, and want to graph the above function as a surface. How would I go about doing it?

IKavanagh
  • 6,089
  • 11
  • 42
  • 47
Maurdekye
  • 3,597
  • 5
  • 26
  • 43
  • 2
    I assume you've tried `surf`, which is the first hit in Google for "Matlab surface graph" and worked through all of the [examples here](http://www.mathworks.com/help/matlab/learn_matlab/creating-mesh-and-surface-plots.html)? – horchler Nov 01 '14 at 02:29
  • I have, and have also watched a few tutorial videos, but I was wondering how I would use two separate variables. In this example it looks like they use a 'meshgrid'; any idea how I would transform two distinct variables into a single meshgrid? – Maurdekye Nov 01 '14 at 02:31
  • 2
    Yes, `meshgrid` will be pretty useful. I bet if you read through the documentation for the function and try some things you'll learn a lot and even get it to work. As it stands, your question is a low quality "do it for me" type. You should show your code; what you tried. Indicate exactly what is not working, any error messages in their entirety, and what you expected the output to be. – horchler Nov 01 '14 at 02:37
  • You should see if you get similar plot using `meshgrid`. That is homework :). – Autonomous Nov 01 '14 at 03:08

1 Answers1

1

You can use ezsurf to plot the surface defined by a two-variable function. Of course, this can be done by surf as well by manually defining the (x,y) grid.

ezsurf('sin(x)/y^(log(x))')

Plotting a surface defined by two variables

Autonomous
  • 8,935
  • 1
  • 38
  • 77