Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Using surf function to plot slices of a 3D matrix

  1. Apr 28, 2010 #1
    Using "surf" function to plot slices of a 3D matrix

    Hello

    I have a 100x100x100 matrix called "A" and want to plot 2D slices of it to get a feel of where the global minima are (since there is no other way which I know of visualising it... is there?)

    If I take a slice of the third component, eg. "surf(A(:,:,50))" it will plot it fine, but I cannot do this for the other two:

    Code (Text):
    >>> surf(A(1,:,:))
    ??? Error using ==> surf at 74
    Z must be a matrix, not a scalar or vector.
    Is there a simple workaround for this?

    Thanks
     
  2. jcsd
  3. Apr 28, 2010 #2
    Re: Using "surf" function to plot slices of a 3D matrix

    Use surf(squeeze(A(1,:,:))). Squeeze will turn the 1 x 100 x 100 array into a 100 x 100 array.
     
  4. Apr 28, 2010 #3
    Re: Using "surf" function to plot slices of a 3D matrix

    Brilliant- thanks very much!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Using surf function to plot slices of a 3D matrix
  1. 3D plot using Matlab (Replies: 1)

Loading...