Display negative values on logarithmic graph

Hi, I want to plot a set of data where the values oscillates around 0 but the amplitude decays exponentially. It is normally plotted with two different logarithmic yaxis on top of each other. With the lower one in reverse order. Can that be done in Matlab?

 採用された回答

Grzegorz Knor
Grzegorz Knor 2012 年 3 月 8 日

0 投票

Plot the logarithm of the absolute value of y multiplied by sign of y, and the change labels:
x = linspace(0,3,10000);
y = 1e6*exp(-x).*(sin(10*x)-0.5);
plot(x,y)
figure
Y = sign(y).*log10(abs(y));
plot(x,Y,'.')
yl = get(gca,'ytick');
set(gca,'yticklabel',sign(yl).*10.^abs(yl))

2 件のコメント

bent
bent 2012 年 3 月 8 日
Thank you, that's just what I wanted.
Ainray
Ainray 2023 年 3 月 22 日
編集済み: Ainray 2023 年 3 月 22 日
It give wrong ticks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLog Plots についてさらに検索

タグ

質問済み:

2012 年 3 月 8 日

編集済み:

2023 年 3 月 22 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by