【问题标题】:How to flip the x-axis?如何翻转x轴?
【发布时间】:2015-08-05 06:56:43
【问题描述】:

我正在绘制 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]

【问题讨论】:

    标签: matlab plot matlab-figure


    【解决方案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);
    

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

    【讨论】:

      猜你喜欢
      • 2021-05-11
      • 1970-01-01
      • 2013-08-16
      • 1970-01-01
      • 1970-01-01
      • 2022-11-28
      • 2010-12-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多