1

I have two functions f and g. Both are dependent on three variables being x, y and z. The functions and boundaries of x, y and z are provided as follows:

x = 150:5:250;
y = 0.2:0.05:0.3;
z = 1:0.1:2;
f = 20./(x.^0.2) .* (y.^0.3) .* (z.^0.01);
g = x .* y .* z

How can both of the functions be plotted in one graph?

Himanshu Mishra
  • 8,510
  • 12
  • 37
  • 74
Neeraj Bhanot
  • 35
  • 1
  • 6
  • 5
    Try to sketch it first on a sheet of paper and you will realize that this is going to be difficult. – cel Jun 21 '15 at 17:22
  • What about plotting this only for f=1 and g=1? For other values it is a scaled version of this shape. This way you would reduce it to 3d. – Daniel Jun 21 '15 at 17:47
  • First -> The vectors `x`,`y`,`z` are not the same dimension. Second -> In our 3d-world a 4d-plot is going to be a fundamental problem. I see the possibility to use a scatter 3d-plot with different colors. See the [documentation of `scatter3`](http://ch.mathworks.com/help/matlab/ref/scatter3.html#btr5_il-1) for that. OR use [`slice`](http://ch.mathworks.com/help/matlab/ref/slice.html) to display a part of it. – Matt Jun 21 '15 at 18:06
  • You can do a color-coded 3-D plot, where the color is determined by the value of the function at that location. However, you'll have to play all sorts of games with the transparency/translucence, otherwise you will only be able to see what is on the exterior of the domain. I'd suggest making a movie so that one of the dimensions is across the individual frames thereof. For instance, you can let each frame be a slice along z. – AnonSubmitter85 Jun 21 '15 at 18:22
  • 3D functions that fill all of space are difficult to plot. The only static plots I can think of now are slices, or 3D contours (ie, a set of 2D surfaces within the 3D space) http://docs.enthought.com/mayavi/mayavi/_images/enthought_mayavi_mlab_contour3d.jpg . Interactive plots, where you can, say, move a section plane through the 3D space are also useful. You'll need a good, full, 3D library like VTK (or MayaVi in Python), probably matplotlib or Matlab won't have enough power. See http://docs.enthought.com/mayavi/mayavi/auto/examples.html – tom10 Jun 21 '15 at 19:43
  • I am afraid it is hard to give you advice regarding how to visualize 4D data without knowing more about what you want to do. To begin with I would say that it is hard to visualize 4D data in a good way. This means that you most likely will need to write your own code. The guess is that you could probably use points with different density in a 3D space. This will be problematic if both plots will overlap. Then you will need some way to separate the plots from each other and this is where the need of (typical) example data kicks in. – patrik Jun 22 '15 at 11:07
  • Voting to close. Without some specific guidance on what type of plot the OP wants (eg, what aspect of the function they want to visualize), this question if far too vague. – tom10 Jun 22 '15 at 17:36

0 Answers0