Surface plots and mesh

3 次查看(过去 30 天)
Baalzamon
Baalzamon 2013-3-12
% So here is the problem, Say I have the following arrays:
x = [1, 2, 3];
y = [1, 2, 3];
A = [1, 1, 1; 1, 2, 1; 1, 1, 1];
Using surface plots:
surf(x,y,A)
I would expect (and want) the plot to be a 3x3 grid with A(2,2) at a higher elevation. What I get is a grid of 2x2!
Following this with a 5x5 grid of pyramid numbers I get a 4x4 grid output from surf. I guess I would like the point plotted to be in the centre of a "square"?
Anyway to change this behaviour?

回答(1 个)

Walter Roberson
Walter Roberson 2013-3-12
There is no way to change that behavior. surf() always creates points from the interior vertices, and since there are N-1 interior vertices for a side of length N, there will always be one fewer row and columns.
The closest you can get is to use image() (if you do not need something 3D) or to do a texture mapping onto a patch (or surface) if you need something 3D.

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by