Matlab中imagesc()的非均匀轴

5

问题:是否可以在非均匀轴上说明图像?

详情:

我需要将一个多维时间序列说明为一幅图像。但是这个时间序列的时间网格非常不均匀。以下是一个例子:

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

可以很好地处理figure, plot(t, values);。但是根据文档,imagesc()会将t转换为t(1)t(end)之间的统一时间:

imagesc(x,y,C)将C显示为图像,并使用向量x和y指定x和y轴的范围。

因此,命令:

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

在统一的时间网格上说明图像。

enter image description here enter image description here

编辑:可以使用更高的统一分辨率重新采样时间序列。但我的时间序列已经非常大了。

3个回答

5

MATLAB有一个pcolor函数,该函数可以准确地实现你所需的功能。

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;

然而,这个pcolor或surface方法会在边缘删除一列和一行! - zlin

4
尝试从文件交换中心下载uimagesc。 图片描述在此处:enter image description here

谢谢Natan。它运行良好,但不适用于我的2GB矩阵(时间序列)。在某些时候,它会使用更高的分辨率重新采样数据。例如,10个时间点的“t”变成了269个点。 - Serg
如果您有一个2GB的矩阵,将其重新采样为合理大小(使用imresize或类似工具)不是更合理吗?一个1920x1200x24位的屏幕只能显示约10MB的信息,给它一个2GB的矩阵有什么好处呢? - bla
这是正确的,但我需要在放大时看到实际的时间刻度。假设该图表显示了某些数据的24小时情况,而我需要查看特定1秒钟内发生了什么。谢谢。 - Serg
请在Matlab中心查看“jplot”。它可以根据缩放级别动态重新采样日期。 - tgoossens

2

解决方案

尝试使用surface进行非均匀间距。

首先,创建一个与您的输入数据大小相同的三维xyz表面:

m = 10;
n = 3;
t = sort(rand(m, 1));  % non-uniform time
values = randn(m, n);  % some random values
x = repmat(t,1,n);
y = repmat(1:n,m,1);
z = zeros(size(y));

接下来,对你的数值进行颜色映射。有一个很好的工具发布在MathWorks文件交换中心,real2rgb,可以为你完成这个任务:

cdata = real2rgb(values);  % Where size(cdata) = [m n 3]

最后,绘制表面。您甚至可以变得花哨并设置透明度。
surface(x,y,z,cdata,'EdgeColor','none','FaceColor','texturemap',...
  'CDataMapping','direct');
alpha(0.3)

enter image description here


谢谢,看起来很有趣。我等到离电脑近了再去查看。 - Serg
然而,这个pcolor或surface方法会在边缘删除一列和一行! - zlin

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接