본문으로 건너뛰기
Hub Nexus
업데이트됨

작성자아직 작성자가 없습니다맡기

개선할 점이 보이나요? 변경을 제안하세요.

후원

이 페이지는 공개 상태입니다.

Introduction

This article is on the topic of creating Bode plots in MATLAB. The quick answer is use the bode command. However, the bode command has several options and the plots generated by the bode command are not easily reformatted. The default formatting of most MATLAB plots is good for analysis but less than ideal for dropping into Word and PowerPoint documents or even this website. As a result this article presents an alternative that requires more lines of code but offers the full formatting flexibility of the generic plot command.

MATLAB's Bode Command

The basic bode command is as follows

>> bode(LTI_SYS)

where

The bode command will automatically call gcf which will put the bode plot on the current figure. If no figure exists then one is created by gcf.

If you wish to specify the frequency points at which LTI_SYS is plotted then create a frequency vector using logspace or linspace as follows

>> freqVec = logspace(-1, 3, 5000);
>> bode(LTI_SYS, freqVec * (2*pi))

where

  • freqVec is a vector of 5000 frequencies, in Hz, spaced evenly on a log scale from 10-1 to 103
  • pi is a MATLAB constant equal to the value of π and in this case it is used to convert freqVec to rad/sec as it is passed to the bode command

In order to get the magnitude and phase at each frequency point the bode command must be called with output arguments such as

>> [mag, phase] = bode(LTI_SYS);

or

>> [mag, phase] = bode(LTI_SYS, freqVec * (2*pi));

where

  • mag is the magnitude (not in dB) at each point in freqVec
  • phase is the phase (in degrees) at each point in freqVec

The mag and phase variables must come out as 3D arrays. Assuming LTI_SYS is SISO then the commands below will convert mag and phase into the vectors you would expect

>> mag = mag(:);
>> phase = phase(:);
>> mag = db(mag);  % to get the magnitude in 20log dB

Issues with the bode command

The main issue with the bode command is reformatting of the plot. The bode command appears to use a normal semilogx plot and then apply patches ro something similar to the figure. This can lead to odd behavior when attempting to create multi-line titles, reformat line widths or font sizes, etc. The normal relationship of axes to figure is just not quite present.

Where this page came from

This page was imported from Wikibooks. From “MATLAB Programming” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

이 페이지가 속한 매거진MATLAB Programming

언어English

이용 허락: CC BY-SA 4.0 · 출처 en.wikibooks.org

견해

코멘트

Spinner Logo
버전: 2CC0 1.0 (퍼블릭 도메인)
The runaway star that left the Tarantula Nebula
버전: 2CC0 1.0 (퍼블릭 도메인)
The Eagle Nebula, seen in the infrared
버전: 2CC0 1.0 (퍼블릭 도메인)
The Cosmic Cliffs are not cliffs
버전: 2CC0 1.0 (퍼블릭 도메인)
The recommended targets are real, but the largest health gain is between doing nothing and doing a little. That is the part worth knowing if you are starting from nothing.
버전: 2CC0 1.0 (퍼블릭 도메인)
Sleep is not one state but a cycle through several, each doing different work. Most sleep disorders are a failure to complete that cycle rather than a shortage of hours.
버전: 2CC0 1.0 (퍼블릭 도메인)
Four nebulae that revealed the shape of our galaxy