MATLAB imagesc命令不适用于非均匀间隔的y轴值 [英] MATLAB imagesc command not working for non-evenly spaced y-axis values

查看:2194
本文介绍了MATLAB imagesc命令不适用于非均匀间隔的y轴值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Ok, so this is starting to get very frustrating.

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

I have the following code: (scannedResponse, thetaAxis given here).

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轴是错误的,并且线不是它们应该的位置。

So I get two images. One made with pcolor, and one made with imagesc. The pcolor image is correct, because the y-axis is correct, and the lines are where they are supposed to be. The imagesc is wrong, because the y-axis is wrong, and the lines are not where they are supposed to be.

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

As you can see, the lines of the imagesc image do not agree with the lines of the pcolor image. I cannot seem to get the imagesc y-axis to agree with the pcolor y-axis, and thus give me a similar plot. How do I go about doing that?

P.S。我已经尝试了使用设置(gca,'Ydir','普通')命令等来翻转图像的y轴的全部色域等无济于事。

P.S. I have already tried the full gamut of flipping the y-axis for imagesc, using the set(gca,'Ydir', 'normal') command, etc etc to no avail.

谢谢。

推荐答案

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

The problem is that thetaAxis contains non-equally spaced values. pcolor can deal with that, imagesc can't. A solution is to interpolate your data to get them on an equally spaced grid:

% 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(scansResponse,2),thetaAxis,scansResponse);着色interp

Except for the implicit smoothing that pcolor appears to do, this plot looks identical to the one using pcolor(1:size(scannedResponse,2), thetaAxis, scannedResponse); shading interp.

这篇关于MATLAB imagesc命令不适用于非均匀间隔的y轴值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆