Display negative values on logarithmic graph

16 Ansichten (letzte 30 Tage)
bent
bent am 8 Mär. 2012
Bearbeitet: Ainray am 22 Mär. 2023
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?

Akzeptierte Antwort

Grzegorz Knor
Grzegorz Knor am 8 Mär. 2012
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 Kommentare
bent
bent am 8 Mär. 2012
Thank you, that's just what I wanted.
Ainray
Ainray am 22 Mär. 2023
Bearbeitet: Ainray am 22 Mär. 2023
It give wrong ticks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Log Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by