Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-uniform axis of imagesc() in Matlab

Question: is it possible to illustrate an image on non-uniform axis?

Details:

I need to illustrate a multidimensional timeseries as an image. But the time grid of this timeseries is very non-uniform. Here is an example:

m = 10;
n = 3;
t = sort(rand(m, 1));  % non-uniform time
values = randn(m, n);  % some random values

The figure, plot(t, values); handles it well.

But imagesc() converts t into uniform time between t(1) and t(end) according to documentation:

imagesc(x,y,C) displays C as an image and specifies the bounds of the x- and y-axis with vectors x and y.

Therefore, the command:

figure, imagesc(t, 1 : n, values'); colorbar;

illustrates the image on uniform time grid.

enter image description hereenter image description here

Edit: It's possible to re-sample the timeseries with higher uniform resolution. But my timeseries is already very large.

like image 722
Serg Avatar asked Dec 20 '12 17:12

Serg


2 Answers

There is pcolor function in MATLAB. This function does exactly what you're asking.

m = 10;
n = 3;
t = sort(rand(m, 1));  % non-uniform time
values = randn(m, n);  % some random values
figure
plot(t, values);
figure
pcolor(t, 1 : n, values'); 
colorbar;
like image 193
mc2 Avatar answered Nov 06 '22 16:11

mc2


try uimagesc from the file exchange.

enter image description here

like image 4
bla Avatar answered Nov 06 '22 16:11

bla