You are on page 1of 1

Cdigo MATLAB

i0 = input('Digite o valor inicial da corrente:');


v0 = input('Digite o valor inicial da tenso(sinalizar a tenso pelo
sentido da corrente):');
R = input('Digite o valor de R:');
L = input('Digite o valor de L:');
C = input('Digite o valor de C:');
format short
alfa = R/(2*L)
w = 1/sqrt(L*C)
s1 = -alfa + sqrt(-(w^2 - alfa^2))
s2 = -alfa - sqrt(-(w^2 - alfa^2))
derI0 = -(1/L)*(R*i0 + v0)
syms t

if alfa > w
G = [1 1;s1 s2]
H = [i0 ; derI0]
A = G \H;
i1 = (A(1,1))*exp(s1*t)+ (A(2,1))*exp(s2*t);
disp(i1)
fprintf('Amortecimento Supercrtico')
tvalor =linspace (0,5);
y = double(subs(i1,t,tvalor));
plot (tvalor,y)
ylabel('i(A)')
xlabel('t(s)')
elseif alfa == w
A2 = i0;
A1 = derI0 + (alfa*A2);
i2 = A1*t*exp(-alfa*t)+ A2*exp(-alfa*t);
disp(i2)
fprintf('Amortecimento Crtico')
tvalor=linspace (0,5);
y = double(subs(i2,t,tvalor));
plot (tvalor,y)
ylabel('i(A)')
xlabel('t(s)')

elseif alfa < w


wd = sqrt(w^2 - alfa^2)
B1 = i0
B2 = (derI0 + (alfa*B1))/ (wd)
i3 = B1*cos(wd*t)*exp(-alfa*t)+ B2*sin(wd*t)*exp(-alfa*t);
disp(i3)
fprintf('Caso de Subamortecimento\n')
tvalor=linspace (0,5);
y = double(subs(i3,t,tvalor));
plot (tvalor,y)
ylabel('i(A)')
xlabel('t(s)')
end

You might also like