Home > NoiseTools > private > niceticks.m

# niceticks

## PURPOSE

y=nicescale(x) - calculate a nice set of values for ticks, based on x

## SYNOPSIS

function y=niceticks(x,factor)

## DESCRIPTION

    y=nicescale(x) - calculate a nice set of values for ticks, based on x

     x: maximum value along scale
     y: array of ticks

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SOURCE CODE

    0001 function y=niceticks(x,factor)
    0002 %y=nicescale(x) - calculate a nice set of values for ticks, based on x
    0003 %
    0004 % x: maximum value along scale
    0005 % y: array of ticks
    0006
    0007 if nargin<2; factor=1; end
    0008
    0009 % closest power of 10 smaller than x:
    0010 a = 10^floor(log10(x));
    0011 a=a/factor;
    0012 if (x/a) <= 2
    0013     a = a/2;
    0014 elseif (x/a) > 5
    0015     a = a*2;
    0016 end
    0017
    0018 y = a * (0:floor(x/a));