Reputation: 225
I have Z = f(x,y). I have discrete values of Z. I want to get a 2-D plot where the magnitude of Z is represented by the color of the points. The color should vary gradually as the magnitude of Z.
I prefer a Octave or MATLAB solution, but any other software is fine. Any help is much appreciated.
Upvotes: 0
Views: 312
Reputation: 1018
Create a meshgrid with x and y as arrays:
[X,Y]=meshgrid(x,y)
Then use surf to get discrete colored plot with the z values controlling the intensities.
surf(X,Y,z)
Upvotes: 0
Reputation: 2826
You can use surf()
along with view
in MATLAB. Try this:
figure;
surf(Z);
view(2); % top-down view
You can also enable a color chart that shows color-value correspondence via the colorbar
command.
Upvotes: 1
Reputation: 4549
One possible way is to use imagesc:
Example:
Z = rand(10);
imagesc(Z)
Upvotes: 3