MATLAB Matlab function surf, redefining axes values

AI Thread Summary
The user initially faced challenges plotting a matrix using Matlab's surf function, as the axes defaulted to indexing locations instead of specified (x,y) coordinates. They had separate matrices for x and y coordinates but were unsure how to implement them. The solution involved organizing the x and y coordinates into single column matrices and ensuring the dimensions of the plot matrix matched. By using the surf function with the correct inputs, they successfully plotted the data. The issue was resolved by correcting the matrix dimensions used in the function call.
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.
 

Similar threads

Replies
4
Views
2K
Replies
1
Views
4K
Replies
1
Views
2K
Replies
2
Views
2K
Replies
1
Views
5K
Replies
1
Views
2K
Back
Top