Matlab中非均匀的imagesc()轴 [英] Non-uniform axis of imagesc() in Matlab
问题描述
问题:是否可以在非均匀轴上说明图像?
Question: is it possible to illustrate an image on non-uniform axis?
详细信息:
我需要将多维时间序列说明为图像。但是这个时间序列的时间网格是非常不均匀的。这是一个例子:
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
数字,图(t,值);
处理得很好。
但 imagesc()
将 t
转换为统一时间在 t(1)
和 t(结束)
之间根据文件:
But imagesc()
converts t
into uniform time between t(1)
and t(end)
according to documentation:
imagesc(x,y,C)将C显示为图像,并使用向量x和y指定
x和y轴的边界。
imagesc(x,y,C) displays C as an image and specifies the bounds of the x- and y-axis with vectors x and y.
因此,命令:
figure, imagesc(t, 1 : n, values'); colorbar;
说明统一时间网格上的图像。
illustrates the image on uniform time grid.
编辑:可以重新对时间序列进行重新采样统一分辨率。但我的时间序列已经很大了。
It's possible to re-sample the timeseries with higher uniform resolution. But my timeseries is already very large.
推荐答案
解决方案
尝试使用 surface
表示非均匀间距。
Try using surface
for non-uniform spacing.
首先,创建一个与输入数据大小相同的3D xyz曲面:
First, create a 3D xyz surface of the same size as your input data:
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 ,这可以为你做到这一点:
Then, colormap your values. There is a nice tool posted to the mathworks file exchange, real2rgb, that can do this for you:
cdata = real2rgb(values); % Where size(cdata) = [m n 3]
最后,绘制曲面。你甚至可以设置透明度。
Lastly, plot the surface. You can even get fancy and set the transparency.
surface(x,y,z,cdata,'EdgeColor','none','FaceColor','texturemap',...
'CDataMapping','direct');
alpha(0.3)
这篇关于Matlab中非均匀的imagesc()轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!