multiple bode plots on same graph

396 views (last 30 days)
aaa on 14 Dec 2011
Answered: mjcStudent on 3 Apr 2019
Does anyone know how to plot multiple bode plots using the "bode" function? I know that the easiest way to do this would be to use
bode(sys1, sys2)
but this assumes that both of these functions are written in the "tf" form.
The problem i am having is that I would like to plot an array of data, with a 'tf' data on the same plot. However, I can't quite get it to work the way i want.
So what i want is to plot the bode plot first
and then be able to plot the magnitude and phase in the corresponding bode figure which uses the code
semilogx(f, data(:,1))
for the magnitude.
has anyone done this before?

Sign in to comment.

Answers (5)

a a
a a on 9 Nov 2015
Edited: a a on 9 Nov 2015
It's working for me:
hold on;
bode(W1); %here you need a system or transfer function or space-state model, etc..
hold off;

Paulo Silva
Paulo Silva on 14 Dec 2011
Maybe something with hold on?!
g = tf([1 0.1 7.5],[1 0.12 9 0 0]);
hold on
g = tf([1],[1 0.12 9 0 0]);

aaa on 14 Dec 2011
unfortunately it is not that simple. my code looks more like
g = tf([1 0.1 7.5],[1 0.12 9 0 0]);
hold on
semilogx(f, data)
the way you have done it assumes both plots are using 'tf'm which could also be plotted just with
  1 Comment
Patricia Darling
Patricia Darling on 1 Mar 2016
I have the same question, none of these answers seem to address the issue of having two different types of data sets on the same bode plot. Did you ever resolve this?

Sign in to comment.

Craig on 16 Dec 2011
You can create an frd object from your data and then plot it like any other LTI object.
[ResponseData,Frequencies]=freqresp(5*tf(1,[1,1,1])); % Example Data
sys1 = tf(1,[1,1]);
sys2 = frd(ResponseData,Frequencies)

mjcStudent on 3 Apr 2019
For my assignment, I had to plot the same graph with different values of one parameter. I wrote this:
for N = 1: .5 : 3 % 6 values
Jl = .002*N; % the parameter to be changed
% skipping most of code
if N == 1 % only create one figure window on the first iteration
hold on % only turn on 'hold' on the first iteration
end % end if
bode(sys); % plot output
title("Stiffness: MA controller");
end % end for loop
hold off
Produces the following output:

Community Treasure Hunt

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

Start Hunting!

Translated by