Tag Archives: Matlab skill

Matlab draw logarithmic coordinates!

In many engineering problems, some characteristics of data can be seen more clearly through logarithmic transformation of data. The curve of data points depicted in logarithmic coordinate system can directly represent logarithmic transformation.
There are two kinds of logarithmic transformation: double logarithmic transformation and single axis logarithmic transformation. Loglog function can be used to achieve the double log coordinate transformation, semilogx and Semilogy functions can be used to achieve the single axis log coordinate transformation.
Loglog (Y) means that the x and Y coordinates are logarithmic coordinates
Semilogx (Y) means that the x axis is a logarithmic coordinate system
Semilogy (…). That means that the Y-axis is a logarithmic coordinate system
So plotyy has two y axes, one on the left and one on the right
Example 1: Create a simple loglog with the square tag.
Solution: Enter a command
X = logspace (1, 2);
loglog(x,exp(x),’-s’)
Grid on % annotated grid
The produced figure is:

Example 2: Create a simple semi-logarithmic graph.
Solve input command:
x=0:.1:10;
semilogy(x,10.^x)
The produced figure is:

example 3: draw function graph, logarithmic graph and semilogarithmic graph of y=x^3.
Solution: Enter in the window:
x=[1:1:100];
Subplot (2,3,1);
plot(x,x.^3);
grid on;
title ‘plot-y=x^3’;
 
Subplot (2, 31);
loglog(x,x.^3);
grid on;
title ‘loglog-logy=3logx’;
 
Subplot (2 filling);
plotyy(x,x.^3,x,x);
grid on;
title ‘plotyy-y=x^3,logy=3logx’;
 
Subplot (2, 4);
semilogx(x,x.^3);
grid on;
title ‘semilogx-y=3logx’;
 
Subplot (2,3,5);
semilogy(x,x.^3);
grid on;
title ‘semilogy-logy=x^3’;
The produced figure is: