user1985157
user1985157

Reputation:

Plotting data structured (x,y,value)

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:

imagesc(x,y,value) 

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?

Upvotes: 1

Views: 145

Answers (3)

Dani Gehtdichnixan
Dani Gehtdichnixan

Reputation: 1285

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.

Upvotes: 1

bla
bla

Reputation: 26069

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:

Upvotes: 1

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

edit imagesc

Upvotes: 0

Related Questions