MATLAB Answers


How changing the loglog scale x and y axis?

Asked by Emrys
on 3 Oct 2017
Latest activity Commented on by Walter Roberson
on 3 Oct 2017
I need to represent numbers from 0.5 to 50 (0.5 5 50) instead of 1 10 100(standard log log scale) is it possible? how can i do?


Sign in to comment.


2 Answers

Answer by Walter Roberson
on 3 Oct 2017
 Accepted Answer

x = sort( rand(1,40)*49.5 + 0.5 );
y = x.*abs(sin(x));
xlim([0.5 50])
ylim([0.5 50])
nticks = 5;
tickpos = round( logspace(log10(0.5),log10(50), nticks) );
set(gca, 'XTick', tickpos, 'YTick', tickpos)


Thanks for the answer Mr Roberson, but i still have the problem, the way you suggest me doesn't change the scale, what i meant it was that i need to use decade from 0.5 to 5 and 5 to 50. It's like setting the origin in 0.5 instead of 1.
tickpos = [0.5 5 50];
set(gca, 'XTick', tickpos, 'YTick', tickpos)

Sign in to comment.

Answer by David J. Mack on 3 Oct 2017
Edited by David J. Mack on 3 Oct 2017

Have you tried to use semilogy instead of loglog, e.g.:
If you have to use loglog, use the 'XScale'-Property instead:
In both cases you can set the x-tick & the x-axis limit, using:
set(gca, 'XTick',[0.5 5:5:50], 'XLim',[0.5 50]);
Greetings, David


Sign in to comment.