MATLAB Semilog Command


Jump to: navigation, search
MATLAB Semilog Command
Green carrot left.gif
All MATLAB Articles MATLAB's loglog
Green carrot.jpg
In order to prevent spam, users must register before they can edit or create articles.

1 Introduction

The semilogx or semilogy commands plot data with 1 axis linear and the other axis log scale. The semilogx command plots the data on the x-axis on a log scale. For controls this is particularly useful when manually creating a bode plot.

2 Bode Plots

The MATLAB bode plot is very convenient but when the plot needs to be formatted then the bode command makes this difficult. As a result this author (Gabe 13:30, 20 April 2008 (CDT)) creates bode plots using the following commands

 >> freqVec = logspace(-1, 3, 5000);
 >> [mag, phs] = bode(sys, freqVec * (2*pi));
 >> mag = db(mag(:));
 >> phs = phs(:);
 >> figure;
 >> subplot(2, 1, 1)
 >> semilogx(freqVec, mag)
 >> grid on
 >> title('System Bode Plot')
 >> ylabel('Magnitude (dB)')
 >> subplot(2, 1, 2)
 >> semilogx(freqVec, phs)
 >> grid on
 >> ylabel('Phase (deg)')
 >> xlabel('Frequency (Hz)')