Konrad Viltersten
Konrad Viltersten

Reputation: 39058

Visualizing a 3D data set

I've got a matrix of 200 by 50. I'd like to show a grid colored accordingly to the values with 50 on the y-axis and 200 on the x-axis. I tried to play with mesh but:

  1. I get a lot of white space between the colored parts (I'd like the area to consist of a full fill of the squares, preferably with a frame around each too) and

  2. the angle is 3D-ish, while I'd like it to be "straight from above".

Is mesh the correct tool for me or should I use something else?

This far, I've been using the following code. I'm open to comments and suggestions.

surf(values, 'EdgeColor','none');
view(90, 90);

Upvotes: 1

Views: 297

Answers (1)

bla
bla

Reputation: 26069

use surf instead, for example:

% Create a grid of x and y points
g= linspace(-2, 2, 20);
[X, Y] = meshgrid(g, g);

% Define the function Z = f(X,Y)
Z = 10*exp(-X.^2-Y.^2);

% "phong" and "gouraud" lighting are good for curved, interpolated surfaces. 
surf(X, Y, Z); 
view(30, 75);
colormap(jet(256));
shading interp;
light;
lighting phong;

enter image description here

Or if you really want a "view from above" use view(0, 90);

enter image description here

Upvotes: 4

Related Questions