%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Ejemplo de un diagrama de Bode de un sistema de cuarto orden con cinco
% factores básicos
%
% Se muestra que tanto para la fase como para la amplitud de la función de
% transferencia G, el resultado es la suma de los efectos trazados por
% separado de los cinco factores básicos G1, G2, G3, G4 y G5
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear
clc


w1  = 0.1; 
w2  = 100; 

num1 = [4];

den1 = [1];

G1 = tf(num1,den1)

bode(G1,{w1,w2}); grid;


hold on

num2 = [1];

den2 = [1,0];

G2 = tf(num2,den2)

bode(G2,{w1,w2});grid


num3 = [1];

den3 = [2,1];

G3 = tf(num3,den3)

bode(G3,{w1,w2});grid


num4 = [0.5,1];

den4 = [1];

G4 = tf(num4,den4)

bode(G4,{w1,w2});grid


num5 = [1];

den5 = [1/64,(2*0.2/8),1];

G5 = tf(num5,den5)

bode(G5,{w1,w2});grid




%%%%%%%%%% Diagrama total %%%%%%%%%%%%%%%%%%%


k       =  64;

num     = k*[1 2];

factor1 = [1,0];

factor2 = [1,0.5];

factor3 = [1,3.2,64];

f12     = conv(factor1,factor2);

den     = conv(f12,factor3);

G     = tf(num,den)

bode(G,{w1,w2});grid






