This question already has answers here:
Non-uniform axis of imagesc() in Matlab

(3 个回答)


3年前关闭。




好的,所以这开始变得非常令人沮丧。

我有以下代码:( scannedResponsethetaAxis 此处给出)。
clear all
load scannedResponse
load thetaAxis
figure(1); clf(1);
pcolor(1:size(scannedResponse,2), thetaAxis, scannedResponse); shading interp;
figure(2); clf(2);
imagesc(1:s.N.Lsnaps, (thetaAxis),  scannedResponse);

所以我得到两个图像。一种是用 pcolor 制作的,一种是用 imagec 制作的。 pcolor 图像是正确的,因为 y 轴是正确的,并且线条是它们应该在的位置。 imagesc 是错误的,因为 y 轴是错误的,并且线条不在它们应该在的位置。



如您所见,imagesc 图像的线条与 pcolor 图像的线条不一致。我似乎无法让图像 y 轴与 pcolor y 轴一致,因此给我一个类似的图。我该怎么做?

附言我已经尝试了翻转图像的 y 轴的全部色域,使用 set(gca,'Ydir', 'normal') 命令等都无济于事。

谢谢。

最佳答案

问题是 thetaAxis 包含非等距值。 pcolor 可以处理,imagesc 不能。一种解决方案是插入您的数据以将它们放在等距网格上:

% determine interpolation grid: from min to max in equal steps
intpoints = linspace(min(thetaAxis), max(thetaAxis), numel(thetaAxis));
% interpolate the data to fit the new "axis"
int = interp1(thetaAxis', scannedResponse, intpoints);
% plot the interpolated data  using the new "axis"
imagesc(1:size(scannedResponse,2), intpoints, int)
% revert the direction of the y axis
axis xy

除了 pcolor 似乎执行的隐式平滑之外,该图看起来与使用 pcolor(1:size(scannedResponse,2), thetaAxis, scannedResponse); shading interp 的图相同。

关于image - MATLAB imagesc 命令不适用于非均匀间隔的 y 轴值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19083980/

10-10 00:29