Take the 2-minute tour ×

I am trying to plot a dataset using imagesc in Matlab. The dataset is structured like this:

x1  y1  value1
x2  y2  value2
x3  y3  value3

The problem:
when I try to plot it like this:


the figure is only in one dimension.

It works well when I plot it with plot3, using the values for the z-axis.

How can I visualize this dataset using imagesc?

share|improve this question
I have described what I have tried. The problem for me is the shape of the data, every row is one coordinate with a value. I know that this works fine for plot3, but I want it in an imagesc. I have tried reshaping the data, but without any luck. –  user1985157 Jan 16 '13 at 22:38
you can use plot3 and set the view orientation to be looking from the top. Then you will get plot looks like the one you want from imagesc. –  LWZ Jan 17 '13 at 1:35

3 Answers 3

up vote 1 down vote accepted

imagesc needs a matrix structure rather than the 3 vector you mentioned, and assumes that the data is used in uniform space grids. So I'd use scatter instead to begin with. A way to still use imagesc is to interpolate to an uniform grid and construct a matrix out of the 3 vectors you have:

share|improve this answer
Thanky you, Scatter was exactly what I was looking for. I will try your suggestion for imagesc. –  user1985157 Jan 16 '13 at 22:47

If you want to convert your non-uniform data the function you are looking for is griddata. It handles the interpolation and returns a matrix of values. This can be plotted by imagesc, surf or whatever.

scatter is usually the better way, but that depends on your application.

share|improve this answer

Try looking the source code of imagesc function. You can see how it is made. To see it, write:

edit imagesc
share|improve this answer
This brings me to IMAGE, which works the same. –  user1985157 Jan 16 '13 at 22:40

Your Answer


