简体   繁体   English

3d绘图的matlab中的2d矩阵

[英]3d plotting of a 2d matrix in matlab

I have an MxN matrix, Z, and some variable h. 我有一个MxN矩阵,Z和一些变量h。 This matrix represents the points to a solution of a function f(x,y). 该矩阵表示函数f(x,y)的解的点。 h is the spacing between points. h是点之间的间距。 For instance: 例如:

Z(x/h,y/h) = (some value in the Z direction), where x and y are some multiple of h

The domain is from 0 to M*h and the range is from 0 to N*h. 域为0至M * h,范围为0至N * h。 I would like to make a 3d representation of the solution defined by the matrix. 我想对矩阵定义的解决方案进行三维表示。 The graph should be similar to what is produced using the pdetool. 该图应与使用pdetool生成的图类似。 How do I do this in Matlab? 我如何在Matlab中执行此操作?

Here is an example of using surf to plot a 2D matrix in Matlab. 以下是使用surf在Matlab中绘制2D矩阵的示例。

Code: 码:

x_offset = [78, 216, 150, 342, 258, 336;
            168, 174, 174, 222, 150, 246;
            36, 180, 54, 138, 138, 198;
            60, -72, 90, 66, 114, 36;
            -90, -108, -60, 12, 54, -24;
            -42, -78, -138, -42, -12, -114;
            -108, -30, -108, -66, -156, -114;
            -66, -114, -114, -84, -138, -96];
figure(1), surf(x_offset);
xlabel('X'), ylabel('Y'), title('X-offset Error Distribution');

Output: 输出:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM