Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Imagesc with a non equidistant x axis

Subject: Imagesc with a non equidistant x axis

From: Camille Couzi

Date: 24 Nov, 2011 03:25:09

Message: 1 of 6

Hello matlab friends!
I am working with a 2 D matrix which has non equidistant x values, and I would like to plot it in an imagesc.
For example:
A=[ 15 69 52 321 45 2;56 9 85 32 452 48;56 8 26 50 1 0.3];
which is a 3*6 matrix. I have x and y vectors:
x=[10 20 30];
y=[0 0.05 0.15 0.4 1 3 10];
My y values are not equidistantly separated, the difference between the values grow.
If I plot my matrix A just writing:
imagesc(x,y,A)
it returns a plot where the squares are the same size. I want to see that for the firstl values of y, the squares are small, and for the last values of y the squares are bigger.

I hope my explanation is clear... how can I do this? is there a function that does this kind of calculation and plot?
thanks in advance
Camille.

Subject: Imagesc with a non equidistant x axis

From: Bruno Luong

Date: 24 Nov, 2011 07:25:08

Message: 2 of 6

A=peaks(20)
x=cumsum(rand(1,20))
y=cumsum(rand(1,20))

surf(x,y,zeros(size(A)),'CData',A, 'Linestyle', 'none');
view(0,90);

% Bruno

Subject: Imagesc with a non equidistant x axis

From: ImageAnalyst

Date: 24 Nov, 2011 14:11:11

Message: 3 of 6

Clever!

Subject: Imagesc with a non equidistant x axis

From: Camille Couzi

Date: 25 Nov, 2011 01:27:08

Message: 4 of 6

Yes!!!! superclever!!! :-)
Thanks a lot bruno!!!!!!!!!

Subject: Imagesc with a non equidistant x axis

From: Camille Couzi

Date: 1 Dec, 2011 01:38:08

Message: 5 of 6

Hi again!

I used what you suggested Brtuno and it works very well, but now I have small problem when using my data cursor on that figure: the datacursor can only point to the corners of the "squares", not the center (which is what I want and would happen when using imagesc). This is a bit confusing as i want to be able to see the values of my matrix when using the datacursor, which should point to the center of the squares.

How can I do that? I imagine I have to include something in my UpdateFcn of my datacursor object.... but what?

Thanks again for your help!!!
Camille.

Subject: Imagesc with a non equidistant x axis

From: Oliver Woodford

Date: 1 Dec, 2011 10:32:07

Message: 6 of 6

"Camille Couzi" wrote:
> Hello matlab friends!
> I am working with a 2 D matrix which has non equidistant x values, and I would like to plot it in an imagesc.
> For example:
> A=[ 15 69 52 321 45 2;56 9 85 32 452 48;56 8 26 50 1 0.3];
> which is a 3*6 matrix. I have x and y vectors:
> x=[10 20 30];
> y=[0 0.05 0.15 0.4 1 3 10];
> My y values are not equidistantly separated, the difference between the values grow.
> If I plot my matrix A just writing:
> imagesc(x,y,A)
> it returns a plot where the squares are the same size. I want to see that for the firstl values of y, the squares are small, and for the last values of y the squares are bigger.
>
> I hope my explanation is clear... how can I do this? is there a function that does this kind of calculation and plot?
> thanks in advance
> Camille.

You can use interp2 to compute regularly spaced samples from your data, then use imagesc.

Oliver

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us