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

Spa*_*cey 3 matlab plot image

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

我有以下代码:(scanningResponse,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);
Run Code Online (Sandbox Code Playgroud)

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

在此输入图像描述

在此输入图像描述

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

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

谢谢.

A. *_*nda 9

问题是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
Run Code Online (Sandbox Code Playgroud)

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