clc

pkg load control
pkg load symbolic

%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%Datos Ideales%%%%

% wo_ideal=sqrt(1.567*10^7)
% fo_ideal=wo_ideal/(2*pi)
% Q_ideal=wo_ideal/1847
% ho_ideal=1
  
% factor_ideal=ho_ideal*wo_ideal^2
  
%%%%%%%%%%%%%%%%%%%%%%%%%
%%Valores Normalizados%%%
%Propongo C1 = C2 = C
% E12 - 1er: 47nF; E-96: R1=23.2k; R2=11.5k; R3=1.4k
% E12 - 2do: 47nF; E-06: R1=232k; R2=115k; R3=14k

C_norm=4.7e-9;
R1_norm=232e3;
R2_norm=115e3;
R3_norm=14.0e3;

factor_1= 1/(R2_norm*C_norm)
factor_2= 2/(R1_norm*C_norm)
factor_3= (R2_norm+R3_norm)/(R3_norm*R1_norm*R2_norm*C_norm^2)

%%%Par�metros Normalizados%%%%

  ho_normal=factor_1/factor_2;
  wo_normal=sqrt(factor_3/ho_normal);
  fo_normal=wo_normal/(2*pi);
  Q_normal=wo_normal/factor_2;
  
%%%%%%%%%%%%%%%%%%%%%%%%%

s=tf('s');
h_normal=(factor_1*s)/(s^2 + factor_2 * s + factor_3);

[y_step_normal, t_step_normal] = step(h_normal);

[mod_bode_normal, fase_bode_normal, w_bode_normal] = bode(h_normal);

return;