3d graphics of 2d matrices in matlab

I have a matrix MxN, Z and some variable h. This matrix represents points for solving the function f (x, y). h is the distance between points. For example:

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. I would like to make a three-dimensional representation of the solution defined by the matrix. The graph should be similar to what is created using pdetool. How to do it in matlab?

+7
source share
2 answers
+11
source

Here is an example of using surf to build a 2D matrix in Matlab.

The 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:

enter image description here

+3
source

All Articles