Matlab function surf, redefining axes values

  • Context: MATLAB 
  • Thread starter Thread starter davidnuke85
  • Start date Start date
  • Tags Tags
    Axes Function Matlab
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 10K views
davidnuke85
Messages
2
Reaction score
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
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.