如何翻转x轴?

How to flip the x-axis?

我正在绘制 FMCW 雷达的振幅重建图。

我只想翻转里面的图。但是 x 轴应该是相同的。我该怎么办。下面是我的绘图代码。

for i = 1:2500                                %%%% dividing each row by first row.
 resd(i,:) = res3(i,:)./res3(1,:);
end

f = fs/2*linspace(0,1,nfft/2+1);                   %%%% defining frequency axes
K = BW/Tm;
t = f/K;
deltaf = 1/max(t);
fmax = 1 / t(2)-t(1);
f1 = 0:deltaf:fmax;
% f1 = fmax:deltaf:0;
f2 = f1 + fc;

%%%%%% Amplitude reconstruction 
figure(1),plot(f2,abs(resd));
[![enter image description here][1]][1]

正如在 axes documentation 中找到的那样,它只是:

set(gca,'XDir','reverse')

如果您只想翻转标签,只需 flip 个标签:

plot(1:10,1:10)
set(gca, 'XTickLabel', flipud( get(gca, 'XTickLabel') ))

或者对于 Matlab R2014b 或更高版本更简单一点:

a = gca;
a.XTickLabel = flipud(a.XTickLabel);

但请注意,调整图形大小时标签不会再更改。所以提前定好尺寸