You are on page 1of 2

%PORBLEMA_2 0PAM

clear all;
close all;
clc
fprintf('Parametros del Sistema...\n');
Ri=input('Ingrese el valor de Ri = ');
Rf=input('Ingrese el valor de Rf = ');
L=input('Ingrese el valor de L = ');
C=input('Ingrese el valor de C = ');
fprintf('\nFuncion de Transferencia del Sistema...\n');
num=[-Rf/Ri 0 0]
den=[1 (L+Rf*Ri*C)/(L*Ri*C) Rf/(L*Ri*C)]
printsys(num,den)
fprintf('\nRaices del Sistema...\n');
roots(den)
disp('Presione tecla para continuar...'); pause;
fprintf('\nEspacio de estado...\n');
[A,B,CC,D]=tf2ss(num,den)
figure;step(num,den)
disp('Presione tecla para continuar...'); pause;
figure;rlocus(num,den)
disp('Presione tecla para continuar...'); pause;
figure;bode(num,den)
b0=-Rf/Ri;
a1=(L+Ri*Rf*C)/(Ri*C*L);
a2= Rf/(Ri*C*L);
ns=1000;
hs=0.01;
t=[]; Vi=[]; x1=[]; x2=[];Vo=[];
t(1)=0; Vi(1)=0; x1(1)=0; x2(1)=0;
for i=1:ns
t(i+1) = t(i)+hs;
Vi(i+1) = 1;
x1(i+1) = x1(i) + hs*(x2(i) - a1*b0*Vi(i));
% S.Euler
x2(i+1) = x2(i) + hs*(-a2*x1(i) - a1*x2(i) + (a1*a1*b0-a2*b0)*Vi(i));
Vo(i+1) = x1(i) + b0*Vi(i);
end

figure('units','normalized','position',[0 0 .5 1])
plot(t,Vi,'b',t,x1,'-r',t,x2,'-y',t,Vo,'-g'), grid, zoom on
legend('tvsVi(t)','tvsx1(t)','tvsx2(t)','tvsVo(t)','Location', 'Best')
title('Solucin por Metodo de Euler para una entrada ESCALON UNITARIO')
xlabel('t'), ylabel('Vi(t),x1(t),x2(t),Vo(t)')

You might also like