[go: up one dir, main page]

0% found this document useful (0 votes)
319 views2 pages

Bode Plot Code for Engineers

This code generates Bode plots for two different transfer functions. For the first transfer function, it calculates the amplitude ratio and phase angle, plots them on separate subplots on a log-log and semilog scale respectively. It repeats this process for a second transfer function, plotting both on the same figure and applying hold on to overlay the plots.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
319 views2 pages

Bode Plot Code for Engineers

This code generates Bode plots for two different transfer functions. For the first transfer function, it calculates the amplitude ratio and phase angle, plots them on separate subplots on a log-log and semilog scale respectively. It repeats this process for a second transfer function, plotting both on the same figure and applying hold on to overlay the plots.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Problem 2 code

function Bode_plot_code

k=4;
deadt=0;
den=[6 11 6 1];
G=tf(k,den)
n=500;
ww=logspace(-2,3,n);
[mag,phase,ww]=bode(G,ww);
AR=zeros(n,1);
pa=zeros(n,1);
for i=1:n
AR(i)=mag(1,1,i)/k;
pa(i)=phase(1,1,i)-((180/pi)*deadt*ww(i));
end
figure
subplot(2,1,1)
loglog(ww,AR)
axis([0.01 100 0.0001 10])
ylabel('AR/k')
title('Bode plots for Phase Angle and Amplitude Ratio-Problem 2c')
subplot(2,1,2)
semilogx(ww,pa)
axis([0.01 100 -270 0])
xlabel('Frequency (rad/time)')
ylabel('\phi, Phase Angle')

Problem 3a code

function PC_hw6_p3a

k=6;
deadt=2;
num=[1 1];
den=[8 6 1];
G=tf(k*num,den)
n=500;
ww=logspace(-2,2,n);
[mag,phase,ww]=bode(G,ww);
AR=zeros(n,1);
pa=zeros(n,1);
for i=1:n
AR(i)=mag(1,1,i)/k;
pa(i)=phase(1,1,i)-((180/pi)*deadt*ww(i));
end
figure
subplot(2,1,1)
loglog(ww,AR)
axis([0.01 100 0.001 10])
ylabel('AR/k')
title('Bode plots for Phase Angle and Amplitude Ratio')
hold on
subplot(2,1,2)
semilogx(ww,pa)
axis([0.01 1 -180 0])
xlabel('Frequency (rad/time)')
ylabel('\phi, Phase Angle')

You might also like