Surface plots and mesh

4 ビュー (過去 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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by