FCS Lab
FCS Lab
of Electrical Engineering
Group Members:
Talha Amjad EE -18159 Sec : D
Muzammil Mehmood EE - 18157 Sec : D
Haris Zafar EE - 18160 Sec : D
Bilal Hussain Alvi EE - 18165 Sec : D
CODE:
First we create this file:
function dXdt=rlc_ckt(t,X)
R1=5; % (Kg)
R2=8; % (Kg)
L1=2; % (Nsec/m)
L2=1; % (N)
C=7; % (N/m)
dXdt(1,1)=(-R1/L1)*X(1)-(1/L1)*X(3)+1/L1;
dXdt(2,1)=-(R2/L2)*X(2)-(1/L1)*X(3);
dXdt(3,1)=(1/C)*X(1)-(1/C)*X(2);
Then, we Create a file to type the code name with file name rlc_ckt1:
clear all
close all
clc
X0=[0;0;0];% (Initial speed and position)
[t,X]=ode45('rlc_ckt',[0 50],X0);
figure;
subplot(2,1,1);
plot(t,X(:,1),'r');
hold;
plot(t,X(:,2),'b');
%hold;
plot(t,X(:,3),'g');
xlabel('Time(t)');
ylabel('Position xb / Speed Vb');
legend('i1', 'i2','vc');
title('Plot of RLC Circuit');
grid;
Explanation of State Variables:
There are three state variables in a system i.e; i1, i2 and vc. After the calculation of
these state variables and by graph we can say that initially when t=0s all three state
variables are zero but when the time will t>0s then all state variables will increase and
after sometime i1 and i2 will decrease by time but the vc variable will increase with
respect to time.
OUTPUT :
Q2) Plot the Equations of Mechanical Systems of Lab 3 and Check the
equations for Displacement or Velocity?
Solution:
Code:
First we Create a file with name lab_2:
function dXdt=mass_spring_system (t,X)
Fa=300; %(N)
M1=750; %(Kg)
M2=750; %(Kg)
B1=20; %(Nsec/m)
B2=20; %(Nsec/m)
B3=30; %(Nsec/m)
K1=15; %(N/m)
K2=15; %(N/m)
dXdt(1,1)=X(2);
dXdt(2,1)=-K2/M2*X(1)-((B1+B2)/M2)*X(2)+B3*X(4)/M2;
dXdt(3,1)=X(4);
dXdt(4,1)=B3/M1*X(2)-K1/M1*X(3)-((B1+B3)/M1)*X(4)+Fa/M1;
Then, Create second file with name lab_21 to type following code:
clear all;
close all;
clc;
X0=[0;0;0;0]; % (Initial xb, Vb, xa, Va)
[t,X]=ode45('lab_2',[0 200],X0);
figure;
subplot(2,1,1);
plot(t,X(:,1),'g');
hold;
plot(t,X(:,2),'r');
xlabel('Time(t)');
ylabel('Position xb / Speed Vb');
title('Mass spring system');
legend('xb', 'Vb');
grid;
subplot(2,1,2);
plot(t,X(:,3),'g');
hold;
plot(t,X(:,4),'r');
xlabel('Time(t)');
ylabel('Position xa / Speed Va');
title('Mass spring system');
legend('xa', 'Va');
grid;
Output Graph:
Q3)
�(�) �
��� �������� = =
�(�) 10�2 + 7� + 23
�(�) 1
��� �������� = =
�(�) 10�2 + 7� + 23
MODEL:
RESPONSE:
Code:
System Response:
Code :
s=tf('s');
G1=tf(1,[1 10]);
G2=tf(1,[1 1]);
G3=tf([1 0 1],[1 4 4]);
G4=tf([1 1],[1 6]);
H1=tf([1 1],[1 2]);
H2=1;
P1=feedback(series(G2,G4),G3);
P2=feedback(G1,H1);
sys=feedback(series(P1,P2),H2)
figure()
pzmap(sys)
Transfer Function :