Table of Contents (click for easy navigation)

**What is a Log Plot in MATLAB?****Description****Applications of Log Scale Plot****Types of log plots in MATLAB****Conclusion****References**

## What is a Log Plot in MATLAB?

A logarithmic plot is a nonlinear scale plot utilized when there is a huge scope of amounts. The log transformation can be utilized to make exceedingly skewed distributions less skewed.

## Description

Logarithms were developed in 17^{th} century by
Scottish mathematician John Napier, the inventor of base 10 logarithms and
German mathematician Nicholas Mercator the inventor of base ‘e’ also called
natural logarithms.

A logarithmic scale is exponential so instead of being evenly spaced like in linear scale plots, the number get closer together as they go from 1 to 10 and also from 10 to 100 and from 100 to 1000 and so on. These blocks are known as decades since they have 10 divisions. In engineering, we typically use log scales with base 10 which means every major tick mark is equal to 10 to an exponent and that exponent increases as you proceed increasingly along the log scale.

Fig. 1

Any base can be used for logarithm, though most common are 10, e and 2.

## Applications of Log Scale Plot

Log scale plots are efficiently used in analyzing earthquakes, PH of solution and audio signals. These plots help us to see large range quantities in a small plane.

## Types of log plots in MATLAB

There are two types of log plots in MATLAB:

- Log-log plot
- Semi log plot

### Log-Log Plot

When we use a logarithmic plot with both axes in log scale, i.e. x-axis and y-axis both are represented in log scale, it is called log-log plot.

For example:

Fig. 2

In this figure we can see that both axes are represented in log scale hence called log-log plot.

Command used for this plot is ‘loglog’ if we want to scale both axes logarithmically. First plot a simple exponential function in MATLAB.

MATLAB CODE:

X=linspace(1,100,1000);

Y=x.^3;

Plot(x,y)

Fig. 3

Now use loglog(x,y) command and press enter. We see both the axes are now scaled logarithmically.

Fig. 4

## Semi log plot

If we want to create a log plot with only one axis scaled logarithmically, we use the ‘semilog’ command to plot it in MATLAB.

MATLAB CODE:

Semilogx(x,y) command will scale x-axis logarithmically and semilogy(x,y) command will scale y-axis logarithmically as we can see in fig. 5 and fig. 6 respectively.

Fig. 5

Fig. 6

We can show the grid by using ‘grid on’ command.

loglog(x,y,’-s’)

grid on

Fig. 7

## Conclusion

When we deal with some quantities having a large number of ranges, we can not see the change in plot at every point. We use log plots to see that change at a scale which is divided logarithmically and it makes us easier to show all the ranges in small space. Hence the log transformation can be utilized to make exceedingly skewed distributions less skewed.

## References

MATLAB SOFTWARE