14.4: Log plots

Matlab and Octave Programming for STEM Applications · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    From LibreTexts, under CC BY-NC-SA, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    14.4: Log plots

      When plot values cover more than 1 order of magnitude, it can be more useful to create a logarithm plot rather than a standard lineat plot.

      The MATLAB and Octave functions for logarithm plots are semilogx(), semilogy(), and loglog(). The following examples illustrate the use of these functions.

      Example \(\PageIndex{1}\) semilogy(), log(), semilogx()

      % Log plot examples

      % Create data
      x = 0:5
      y = 2*3.^x

      %% Standard linear plot
      figure;
      plot(x,y,'-s')
      title('Standard linear plot of y = 2*3.^x')
      grid on

      %% semilogy plot
      figure;
      semilogy(x,y,'-s')
      title('semilogy plot of y = 2*3.^x')
      grid on

      %% semilogx plot
      figure;
      semilogx(x,y,'-s')
      title('semilogx plot of y = 2*3.^x')
      grid on
      %% loglog plot
      figure;
      loglog(x,y,'-s')
      title('semilogy plot of y = 2*3.^x')
      grid on

      Solution
      linear plot.png semilogy_plot.png
      semilogx_plot.png loglog_plot.png

      Add example text here.

      .


      This page titled 14.4: Log plots was last modified on Sun, 04 Aug 2024 21:01:54 GMT and is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Carey Smith.