0% found this document useful (0 votes)
18 views

Diagramas de Bode Mathlab

The document contains MATLAB code that generates Bode plots for different transfer functions. The code defines the frequency range, calculates the magnitude and phase of each transfer function, and plots the Bode plots with gain in dB on the first subplot and phase in degrees on the second subplot. Multiple pages of code vary the parameters of the transfer functions.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Diagramas de Bode Mathlab

The document contains MATLAB code that generates Bode plots for different transfer functions. The code defines the frequency range, calculates the magnitude and phase of each transfer function, and plots the Bode plots with gain in dB on the first subplot and phase in degrees on the second subplot. Multiple pages of code vary the parameters of the transfer functions.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

P 13.

4-1
( )

%------------------------------------wmin=1;
wmax=100000;
w = logspace(log10(wmin),log10(wmax));
%------------------------------------K = 2;
z = 20;
p1 = 500;% p2 = 20; p3 = 80;
%-------------------------------------for k=1: length(w)
H(k)=K*(1+j*w(k)/z)/((1+j*w(k)/p1));
mag(k) = abs(H(k));
phase(k) = angle(H(k));
end
%-------------------------------------subplot(2,1,1), semilogx(w/(2*pi),20*log10(mag))
xlabel('Frequency, Hz'), ylabel('Gain, dB')
grid on;
title('Bode plot')
subplot(2,1,2), semilogx(w/(2*pi),phase)
xlabel('Frequency, Hz'), ylabel('Phase, deg')
grid on;

P 13.4-2
( )

%------------------------------------wmin=1;
wmax=100000;
w = logspace(log10(wmin),log10(wmax));
%------------------------------------K = 1;
z1 = 5;
p1 = 50;% p2 = 20; p3 = 80;
%-------------------------------------for k=1: length(w)
H(k)=K*(1+j*w(k)/z1)/((1+j*w(k)/p1));
mag(k) = abs(H(k));
phase(k) = angle(H(k));
end
%-------------------------------------subplot(2,1,1), semilogx(w/(2*pi),20*log10(mag))
xlabel('Frequency, Hz'), ylabel('Gain, dB')
grid on;
title('Bode plot')
subplot(2,1,2), semilogx(w/(2*pi),phase)
xlabel('Frequency, Hz'), ylabel('Phase, deg')
grid on;

( )

%------------------------------------wmin=1;
wmax=100000;
w = logspace(log10(wmin),log10(wmax));
%------------------------------------K = 20;
z1 = 5;
p1 = 50;% p2 = 20; p3 = 80;
%-------------------------------------for k=1: length(w)
H(k)=K*(1+j*w(k)/z1)/((1+j*w(k)/p1));
mag(k) = abs(H(k));
phase(k) = angle(H(k));
end
%-------------------------------------subplot(2,1,1), semilogx(w/(2*pi),20*log10(mag))
xlabel('Frequency, Hz'), ylabel('Gain, dB')
grid on;
title('Bode plot')
subplot(2,1,2), semilogx(w/(2*pi),phase)
xlabel('Frequency, Hz'), ylabel('Phase, deg')
grid on;

P 13.4-3
( )

(
(

)(

)
)

%------------------------------------wmin=1;
wmax=100000;
w = logspace(log10(wmin),log10(wmax));
%------------------------------------K = 0.5;
z1 = 5;
p1 = 50; p2 = 20;
%-------------------------------------for k=1: length(w)
H(k)=K*(1+j*w(k)/z1)/(((1+j*w(k)/p1)*(1+j*w(k)/p2)));
mag(k) = abs(H(k));
phase(k) = angle(H(k));
end
%-------------------------------------subplot(2,1,1), semilogx(w/(2*pi),20*log10(mag))
xlabel('Frequency, Hz'), ylabel('Gain, dB')
grid on;
title('Bode plot')
subplot(2,1,2), semilogx(w/(2*pi),phase)
xlabel('Frequency, Hz'), ylabel('Phase, deg')
grid on;

P 13.4-7

( )

%------------------------------------wmin=1;
wmax=100000;
w = logspace(log10(wmin),log10(wmax));
%------------------------------------K = 0.2;
z1 = 5;
p1 = 25;
%-------------------------------------for k=1: length(w)
H(k)=K*(1+j*w(k)/z1)/(((1+j*w(k)/p1)));
mag(k) = abs(H(k));
phase(k) = angle(H(k));
end
%-------------------------------------subplot(2,1,1), semilogx(w/(2*pi),20*log10(mag))
xlabel('Frequency, Hz'), ylabel('Gain, dB')
grid on;
title('Bode plot')
subplot(2,1,2), semilogx(w/(2*pi),phase)
xlabel('Frequency, Hz'), ylabel('Phase, deg')
grid on;

P 13.4-13
( )

%------------------------------------wmin=1;
wmax=100000;
w = logspace(log10(wmin),log10(wmax));
%------------------------------------K = 2;
z = 200;
p1 = 500;
%-------------------------------------for k=1: length(w)
H(k)=K*(1+j*w(k)/z)/((1+j*w(k)/p1));
mag(k) = abs(H(k));
phase(k) = angle(H(k));
end
%-------------------------------------subplot(2,1,1), semilogx(w/(2*pi),20*log10(mag))
xlabel('Frequency, Hz'), ylabel('Gain, dB')
grid on;
title('Bode plot')
subplot(2,1,2), semilogx(w/(2*pi),phase)
xlabel('Frequency, Hz'), ylabel('Phase, deg')
grid on;

You might also like