Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a log plot in matlab

Tags:

plot

matlab

Is it possible to make a plot in matlab that does not actually take the logs of the values? I'm plotting wide ranges of values and when I try to make a log plot of them, those below 1 become negative. I would just like it to plot the values on a log scale without taking their logs.

like image 918
giroy Avatar asked Aug 11 '10 00:08

giroy


2 Answers

Alternatively, set(gca,'XScale','log') if you have your plot already.

like image 199
Matt Mizumi Avatar answered Nov 03 '22 00:11

Matt Mizumi


Yes, it is possible. Use the loglog command.

The example from the Mathworks website:

x = logspace(-1,2);   % generate a sequence of points equally spaced logarithmically
loglog(x,exp(x),'-s')
grid on

enter image description here

If you do not want both axes to be log scale, use semilogx or semilogy.

like image 24
Larry Wang Avatar answered Nov 03 '22 00:11

Larry Wang