Question: Is it possible in `imagesc` to specify the x-axis a column vector such that the ticks and data points(pixels) are placed on the corresponding points? As far as I understood from the manual you only specify the corners of the image and this is not a problem as long as your data is **evenly spaced** like `100:100:1000`. 

In my case the x-axis consists of 21 elements which are evenly spaced like `1200:50:1700`, whereas the y-axis is the vertical concatenation of two evenly spaced column vectors `200:50:450` and `500:25:725`. My aim is to have the data points(pixels) at the correct locations, but it seems impossible to do so. Is there a workaround?

Answer: 
One option is to make `Y` also evenly spaced, and than use [`repelem`](http://www.mathworks.com/help/matlab/ref/repelem.html):

```
X = 1200:50:1700;
Y = [0 50 100 200:50:450 500:25:725 800];
% set the spacing factor:
spacing = round(diff(Y)/min(diff(Y)));

```

The spacing vector looks like:

```
spacing =
  Columns 1 through 14
     2     2     4     2     2     2     2     2     2     1     1     1     1     1
  Columns 15 through 19
     1     1     1     1     3

```

and defines the distance between elements as multiplications of the smallest distance between elements in the vector.  

We then define our new 'Y' for the image, so it will be evenly spaced, with the smallest space between elements in the vector.

```
% Define the new Y:
Y_spaced = Y(1):min(diff(Y)):Y(end); % = 0:25:800
% some arbitrary data:
data = rand(numel(Y),numel(X));

```

We use the spacing vector as input for [`repelem`](http://www.mathworks.com/help/matlab/ref/repelem.html) to duplicate each row in `data` as much as needed:

```
% spacing the data:
data_spaced = repelem(data,spacing([1 1:end]),1,1);

```

And we can plot it using `imagesc` (either in the matrix `ij` orientation, or in cartesian `xy` orientation):

```
imagesc(X,Y_spaced,data_spaced)
axis xy

```

The result:

[![spaced image](https://i.stack.imgur.com/wX6vw.png)](https://i.stack.imgur.com/wX6vw.png)
Try replace `imagesc` with `surf` command:

```
surf(1200:50:1700, [200:50:450 500:25:725], rand(16,11), 'EdgeColor','none');
view([0 90]);

```

Note: with this way you loose last column and last row compare to `imagesc`, but you can just duplicated these data before displaying.