You are on page 1of 1

clc; clear all;

R=1; L=2; C=1;


den=[1 R/L 1/(L*C)]; num=[0 0 1/(L*C)];
step(12*num,den);
figure, impulse(num,den);
f=60; T=1/f; w=2*pi*f; A=5;
t=0:T/50:10*T;
vi=A*sin(w*t);
vc=lsim(num,den,vi,t);
figure, plot(t,vi,'r',t,vc,'k');
figure, bode(num,den);
y = dsolve('D2y + R/L*Dy + 1/(L*C)*y =
1/(L*C)*12','Dy(0) = 0','y(0) = 0','t')
%ezplot(y,[0 3]), grid on

a1=1/(R*C); a2=1/(L*C); b1=1/(R*C);


t(1)=0; u(1)=1; x1(1)=0; x2(1)=0; %
Condiciones Iniciales
he=0.1; % Periodo de Muestreo
n=input('Numero de particiones: ');
for i=1:n
t(i+1)=t(i)+he;
u(i+1)=1;
x1(i+1)=x1(i)+he*x2(i); % S.Euler
x2(i+1)=x2(i)+he*(-a2*x1(i)-
a2*x2(i)+b1*u(i)); % S.Euler
end

You might also like