allotment of points in meshgrid
6 次查看(过去 30 天)
显示 更早的评论
When I use a meshgrid [X, Y]=meshgrid(1:180,1:180) how the points are devided in the plot? I mean to ask the very first point in the origin is (0,0) or (180,180). The main question is the numbering of the points starts from top of the plot or bottom of the plot?
0 个评论
回答(1 个)
Walter Roberson
2011-11-24
meshgrid() does not create plots: it creates arrays. The arrays created are not necessarily in numerical order: they are in order according to the list of values that are given as arguments to meshgrid(). For example, meshgrid([9 2 5],-3:-1:-6) is valid.
When coordinates are used as (X,Y) coordinates for line plots or surface plots or patches, then the usual convention applies, that the origin is (0,0) in data coordinates, and that the first coordinate is treated as X (usually interpreted as horizontal distance increasing from left to right), and that the second coordinate is treated as Y (usually interpreted as vertical distance increasing from bottom to top).
However, when you create images by way of image() or imagesc() or imshow(), then by default those routines switch the coordinate system so that the first coordinate is still X increasing towards the right, but that the second coordinate as treated as Y increasing from top to bottom.
The actual mechanism for changing the coordinate system so that Y increases downwards, is to set the axes property 'YDir' to 'reverse'; when 'YDir' is 'normal' then the Y increaes from bottom to top. The command shortcut to set the YDir property is
axes xy
for normal bottom to top, and
axes ij
for "reversed" top to bottom.
There is no inherent numbering of points in a plot: there are only coordinate values.
If you were to create a 2D array and were to display it using surf(), and in that call you did not pass in an explicit list of X or Y coordinates, then the implicit ordering used would be that the rows would go up (bottom to top) and the columns would go would go across (left to right). This can be surprising at times but is usually what is wanted.
[I should double-check the default ordering for imag() before saying anything explicit here.]
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!