Matlab function surf, redefining axes values

  • Context: MATLAB 
  • Thread starter Thread starter davidnuke85
  • Start date Start date
  • Tags Tags
    Axes Function Matlab
Click For Summary
SUMMARY

The discussion revolves around using the MATLAB function surf to plot a matrix of values at specified (x,y) coordinates. The user initially faced challenges with the default indexing of axes but resolved the issue by ensuring that the x-coordinates and y-coordinates were formatted as single column matrices. The correct usage of the surf function is demonstrated as follows: surf(x_axis_values, y_axis_values, plot_1_values), where plot_1_values is the m*n matrix containing the corresponding values.

PREREQUISITES
  • Understanding of MATLAB syntax and functions
  • Familiarity with matrix operations in MATLAB
  • Knowledge of 3D plotting concepts
  • Ability to manipulate arrays and matrices in MATLAB
NEXT STEPS
  • Explore advanced features of the surf function in MATLAB
  • Learn about customizing plot aesthetics in MATLAB
  • Investigate other 3D plotting functions such as mesh and contour3
  • Study how to handle errors related to matrix dimensions in MATLAB
USEFUL FOR

Matlab users, data analysts, and engineers who need to visualize data in 3D and require precise control over axis definitions in their plots.

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 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K