Matlab function surf, redefining axes values

In summary, the conversation discusses the use of the surf function to plot a matrix of values at specified (x,y) coordinates. The speaker is having trouble redefining the axes values to correspond to the correct coordinates and is asking for help with this issue. They later discover that the solution is to use single column matrices for the x and y coordinates and to input all coordinates into the plot matrix before using the surf function.
  • #1
davidnuke85
2
0
I have a m*n matrix of values called plot_1. The matrix contains a series of values intended to be plotted at specified (x,y) coordinates. I am trying to plot the matrix using the surf function.

My problem is that the plot comes up with the axes corresponding to the indexing location (row #, column #), and I do not know how to redefine the axes values to correspond to the correct (x,y) coordinates. I have the x-coordinates and y-coordinates in separate matrices ready to be input as the axes values, but I do not know how to tell Matlab to use these matrices rather than the indexing locations. Please let me know if anyone knows of a function to redefine the axes, or if there is a different plotting function that I should use that more easily incorporates user defined axes. Thank you.
 
Physics news on Phys.org
  • #2
Nevermind, I think I found the solution. Looks like all I need to do is put my x-coordinates in a single column matrix (x_axis_values) and my y-coordinates in another single column matrix (y_axis_values) and then put all of my (x,y) coordinates in the m*n matrix (plot_1_values). Then I use the surf function as follows:

surf(x_axis_values,y_axis_values,plot_1_values)

I think I was just using the wrong dimensions for my matrices before and it was giving me error messages. Thanks.
 

Related to Matlab function surf, redefining axes values

1. What is the purpose of the "surf" function in Matlab?

The "surf" function in Matlab is used to create three-dimensional surface plots of data. It is commonly used in scientific and engineering applications to visualize functions and data sets in a three-dimensional space.

2. Can the axes values in a "surf" plot be manually redefined?

Yes, the axes values in a "surf" plot can be manually redefined. This can be done by using the "xlim", "ylim", and "zlim" functions in Matlab to set the limits of the x, y, and z axes respectively.

3. How do I change the color map of a "surf" plot in Matlab?

To change the color map of a "surf" plot in Matlab, you can use the "colormap" function. This allows you to choose from a variety of predefined color maps or create a custom color map.

4. Is it possible to add a color bar to a "surf" plot in Matlab?

Yes, you can add a color bar to a "surf" plot in Matlab by using the "colorbar" function. This will add a color bar to the right side of the plot, showing the range of colors used to represent the data values.

5. Can I save a "surf" plot in Matlab as an image file?

Yes, you can save a "surf" plot in Matlab as an image file by using the "saveas" function. This allows you to save the plot as a variety of image formats, such as png, jpeg, or tiff.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
137
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
772
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
Back
Top