File Exchange

image thumbnail

Bode plot with asymptotes

version (3.41 KB) by Trond Andresen
Bode plot with asymptotes


Updated 22 Sep 2020

View Version History

View License

The function asymp() corresponds to bode(), but it also plots asymptotes for the magnitude and phase graphs. Phase asymptotes are only horizontal and vertical.
asymp() only accepts SISO transfer functions.
If the transfer function also has a time delay, the time delay is ignored
for the phase asymptotes.
asymp() may be called in two ways only, asymp(h), or asymp(h,wmin,wmax).

Cite As

Trond Andresen (2021). Bode plot with asymptotes (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (51)

Ting Yui CHAN

Ka Kiu AU

Eries erik

Zack Long

At the very bottom of the function, the line "set(gca, 'XTickLabel',x);" causes the x-axis labeling to be messed up as Fausto pointed out. If i comment out the code in section "Converting frequency axis to decimal numbers" to remove that functionality, the axis seems to be labeled correctly.


Trond Andresen

To Kris Hoffmann. Try the updated version, hopefully the error is fixed. Thanks!

Kris Hoffman

In some cases, the phase is not calculated correctly. try asymp and bode for MySys = tf([1 0 0],[1 20 100]);. The phase starts at -180 for asymp and starts at 180 for Matlab's bode.

Shaidul Ekram

how do i add this file to the matlab software?

Nate Castle

Works well. Only issue I encountered was that it wasn't displaying correctly when I had it within a subplot.

andy Chang

Thomas Pandolfi

Jon Walderhaug

Trond Andresen

Sorry, saw your correction just now. But the same holds there, asymp(.) and bode(.) both gives amp = 0dB for freq = 1 rad/s.

Fausto Orozco Coy

Excuse me I mean 1 rad/s must have 0 dB gain

Fausto Orozco Coy

This is the transfer function I'm testing:

den=[9.9990e-009 1.0000e+000 0.0000e+000];

this is a video showing when I maximize the figure, the xaxis tick labels don't correspond to the right values (0 rad/s must have 0 dB gain)

Trond Andresen

I am the author of this program. Can you Fausto, tell which transfer function you used that resulted in wrong x-axis tick labels? Then I will check it myself.

Fausto Orozco Coy

awesome function, very useful in the learning of bode diagrams, thanks a lot, however in MatLab 2017 live editor when a figure is open in a figure window the x axis ticks labels don't correspond to the real position.

Alessandro Ballio


Stone Shek

Josep Guasch

Josep Guasch

David Gonzalez Bravo

Very useful!!!

It works perfect, Thanks.

Trond Andresen

Re error msg from Chantal Muller:
If h(s) = num(s)/den(s), the transfer function has to have degree(num) <= degree(den), i.e. be proper or strictly proper.

Robert Stengel

Suggested improvement: Add gridlines. Find all calls to MATLAB's 'bode.m', and add ', grid'.

Robert Stengel

Auto-completion error: 'asymptotic.m' should be 'asymp.m'.

Chantal MULLER

Great !
But I don't understand why the function fails to plot:
wheareas there s no pb with :
I was thinking there was a constrain d°(den)< d°(num), but H7 works.
Anyway, thanks for your function et maybe for your help.

Nico Sjursen

Ed Sar

Britany Chamberlain


good work, thanks

Trond Andresen

I am the author of this function. It works also for the counter-examples given here by other commenters.

Aim Dulay

Rafael Crepaldi

Marcos Gonzalez


The asymptotes does not work for angles in this bandstop-filter:

>> H = tf([1 0 4000.*16000],[1 4000+16000 4000.*16000])

Transfer function:
s^2 + 6.4e007
s^2 + 20000 s + 6.4e007

>> asymp (H)

(Maybe because of the sudden 180 degree phase shift at the bandstop frequency)

Other than that, the program is wonderful <3

Robert Stengel

It doesn't work with this simple test:
f11 = -1.2794;
f12 = -7.9856;
f22 = -1.2709;
F = [f11 f12;1 f22];
G = [-f12;0];
Hx = [1 0];
B22 = inv(-Hx*inv(F)*G)
sys = ss(F, G*B22, Hx,0);
step(sys), grid

Moussab Bennehar

Moussab Bennehar

You're a Geeeeeeeeeeenius
really, great m file


i need keeps saying error at asymp at 19

Nabil al-hadawy

******* Thank you **********
This is function (asymp.m) very nice

John babs

great stuff. thanks!

Joseph Birbiglia

Very good, but there are errors with the following transfer function:

G(s) = (s^2+1)/(s*(s^2+4))

??? Error using ==> colon
Maximum variable size allowed by the program is exceeded.

Error in ==> asymp at 147
set(get(gcf, 'CurrentAxes'),'YTick',magmin:ydelta:magmax);

Trung Duong

It's work. Nice job

Trond Andresen

I am the author of asymp( ).The problem reported by Anton Cervin has now been fixed. Please tell me if problems still remain.

Anton Cervin

It does not seem to work.

>> G = (s+1)/(s*(s+10))

Transfer function:
s + 1
s^2 + 10 s

>> asymp(G)
??? Error using ==> axes
Invalid object handle.

Error in ==> asymp at 120

Zain Gurraya

Jiro Doke

A similar submission:

I would appreciate a more comprehensive help text at the top. The code is documented pretty well. There are some coding styles that could be better (i.e. the while loops). Since you are plotting the asymptotes, maybe the function could return the break frequencies and the corresponding slopes of the asymptotes. It can have the same behavior as BODE, in which if there are no output arugments, then it would create a plot, and if there are outputs, then it wouldn't create a plot.

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!