image - MATLAB imagesc 命令不适用于非均匀间隔的 y 轴值

标签 image matlab plot

<分区>

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

我有以下代码:( scannedResponse , thetaAxis 在这里给出)。

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 制作的,一张是用 imagesc 制作的。 pcolor 图像是正确的,因为 y 轴是正确的,并且线条在它们应该在的位置。 imagesc 是错误的,因为 y 轴是错误的,线条不在它们应该在的位置。

enter image description here

enter image description here

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

附言我已经尝试了翻转 imagesc 的 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); 的图相同着色插值.

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

相关文章:

matlab - 如何使用 syms 来寻址 N 个不同的变量

python - 如何在 matplotlib.pyplot.plot 中重用预定义的线条样式?

c# - 添加到 WPF Canvas 的图像更改大小

objective-c - iPhone 4 和 5 的图像

matlab - 在 Matlab 中哪里可以找到英特尔 MKL

Matlab 将标签放在簇上

linux - 在 Gnuplot 中命名图例条目,同时从数据文件中绘制

Android 照片在 imageview 中,质量很差

android - 我想在 android 中裁剪图像时修复矩形大小

matlab - 如何检测单元格数组中的空单元格?