Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Multiple Bode plots in one figure (Linear Analysis Tool)

205 views
Skip to first unread message

Martina

unread,
Mar 22, 2013, 11:38:08 AM3/22/13
to
Hi there,

I am using MATLAB/Simulink 2011b with the Linear Analysis Tool of Simulink Control Design/Control System Toolbox.

I was wondering whether there is a way of plotting several Bode diagrams into a single figure. For example I have a system with parameters. I do a Bode plot, then change some parameters and do another Bode plot. For comparison reasons I would like those two plots to be in the same figure, the same axes to be precise.

Is that possible? How?

(I am aware of the 'Bode' command, but I think I prefer the GUI of the Linear Analysis Tool.)

Thanks in advance!

Martina

unread,
Mar 25, 2013, 3:58:12 AM3/25/13
to
Any ideas?

kbid...@gmail.com

unread,
Apr 8, 2013, 9:13:07 PM4/8/13
to Martina
% Example 7.39 - LTR Design for Satellite Attitude Control
% from Feedback Control of Dynamic Systems 6th Edition
% by Gene F. Franklin, J. David Powell, Abbas Emami-Naeini

% Modified to plot multiple bode plots...
% Plant
clear all
close all

F= [0 1;
0 0];
G= [0;
1];
H= [1 0];
J= [0];
sys0= ss(F,G,H,J);
H1= [1 0];
sys= ss(F,G,H1,J);

% LQR
w= logspace(-1,3,1000);
rho= 1;
Q= rho*H1'*H1
r= 1;
[K]= lqr(F,G,Q,r)
sys1= ss(F,G,K,0);
[maggk1,phasgk1,w]=bode(sys1,w);
[gm1,phm1,wcg1,wcp1]=margin(maggk1,phasgk1,w)

% Kalman Filter with LTR

maggk=[];
phsgk=[];
gm=[];
phm=[];
wcg=[];
wcp=[];

qscale=1;

for q=1:1:10
gam=q*qscale*G;
Q1=gam'*gam;
rv=1;
[L]=lqe(F,gam,H,Q1,rv);

aa=F-G*K-L*H;
bb=L;
cc=K;
dd=0;
sysk=ss(aa,bb,cc,dd);
sysgk=series(sys0,sysk);
[maggk(q,:),phsgk(q,:),w]=bode(sysgk,w);
[gm(q),phm(q),wcg(q),wcp(q)]=margin(maggk(q,:),phsgk(q,:),w);
end

figure(1)
semilogx(w,20*log10([maggk1(1,:); maggk(:,:)]))
xlabel('Frequency (rad/sec)')
ylabel('Magnitude (dB)')
title('Bode Magnitude')
% axis([w(1) w(1000) -60 60])
grid on

figure(2)
semilogx(w,[phasgk1(1,:); phsgk(:,:)])
xlabel('Frequency (rad/sec)')
ylabel('Phase (deg)')
title('Bode Phase')
grid on
0 new messages