跳轉到內容

MATLAB 程式設計/半對數

來自華夏公益教科書,開放的書籍,面向開放的世界


請注意,此頁面是 ControlTheoryPro.com 上關於 semilogx/y 命令的頁面的副本。

semilogxsemilogy 命令繪製資料,其中 1 個軸為線性,另一個軸為對數刻度。semilogx 命令在對數刻度上繪製 x 軸上的資料。對於控制,這在手動建立 伯德圖 時特別有用。

伯德圖

[編輯 | 編輯原始碼]

MATLAB 伯德圖非常方便,但當需要格式化繪圖時,bode 命令會使此操作變得困難。因此,本文作者 (Gabe 13:30, 20 April 2008 (CDT)) 使用以下命令建立伯德圖

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)')
[編輯 | 編輯原始碼]
華夏公益教科書