In this post we will see the step response of an RLC circuit using a matlab program.The initial conditions are current is 1ma and voltage across capacitor is 2V.
The state space representation of the above circuit is.
Here R =4.1K, L=1.7H and C=1 F
A=[-241.76 -.588;10^7 0] % this is the matrix A B=[1;0] % this is the matrix B C=[0 1] % this is the matrix C D=0 % this is the matrix D sys=ss(A,B,C,D) % ss() is a function to form the state space t=0:.00001:.01; % take several time samples for i=1:1:1001 % make an input matrix of desired length u(i)=10; end [y,t,z]=lsim(sys,u,t,[10^-3 2])% in this function the variable y has output values %t has time values and z has the values of state space variable plot(z(:,1)) %plot the values of X1 which is first state space variable
% using full colon means all values to be more clear z(:,1) means all rows of first column
title(‘state 1’)
plot(z(:,2))
title(‘state 2’)