< MATLAB Programming

Note that this page is a copy of the ControlTheoryPro.com page on semilogx/y commands.

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.

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)')
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.