Reputation: 39058
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:
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
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
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;
Or if you really want a "view from above" use view(0, 90);
Upvotes: 4