This will be my last post in this series on using matlab for designing the compensators.

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’)

### Like this:

Like Loading...

*Related*

## Published by vineethkartha

Hi, I am Vineeth Kartha, I hold a Masters degree in Embedded Systems from BITS Pilani, Goa Campus. I currently work as a Software Developer. I am A free software promoter and electronics hobbyist. In my free time I do a little bit of birding and wildlife photography. I love travelling, reading and blogging.
View all posts by vineethkartha