0% found this document useful (0 votes)
56 views6 pages

Names:-Ali Nawaz Ranjha: COMSATS-Lancaster Dual Degree

The document describes a lab session involving modeling a two-mass spring system in MATLAB. It provides the MATLAB code used to define the system's transfer functions relating displacement and velocity to force for each mass. The code then simulates and plots the impulse responses of each transfer function. Values for the spring constant, damping coefficient, moments of inertia, and masses are input to calculate the specific transfer functions for the two-mass system.

Uploaded by

Ali Nawaz Ranjha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views6 pages

Names:-Ali Nawaz Ranjha: COMSATS-Lancaster Dual Degree

The document describes a lab session involving modeling a two-mass spring system in MATLAB. It provides the MATLAB code used to define the system's transfer functions relating displacement and velocity to force for each mass. The code then simulates and plots the impulse responses of each transfer function. Values for the spring constant, damping coefficient, moments of inertia, and masses are input to calculate the specific transfer functions for the two-mass system.

Uploaded by

Ali Nawaz Ranjha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

COMSATS-Lancaster Dual Degree

Programme

Names:-Ali Nawaz Ranjha


Registeration # DDP-FA10-BTE-008
Control Systems Lab

Lab Session 5:Q#7 of book


(a)Impulse response:Output of system when input is
impulse. Writing our transfer function
Matlab code:%---------------------------% Question#7 ch#3
%---------------------------% Using builtin command
K=input('enter value of spring constant:\n');
D=input('enter value of coefficient of viscous friction:\n');
J=input('enter value of moment of inertia:\n');
M1=input('enter value of first mass:\n');
M2=input('enter value of second mass:\n');
%relating displacement to force
num1=[K]
den1=[M2.*M1 D.*M2 (K.*M2+K.*M1) D.*K 0]
sys1=tf(num1,den1)
num2=[M1 D K]
den2=[M2.*M1 D.*M2 (K.*M2+K.*M1) D.*K 0]
sys2=tf(num2,den2)
t=0:0.01:10;
x=heaviside(t);
subplot(2,2,1)
lsim(sys1,x,t)
grid on
subplot(2,2,2)
lsim(sys2,x,t)
grid on
%relating velocity to force
num3=[K]
den3=[M2.*M1 D.*M2 (K.*M2+K.*M1) D.*K]
sys3=tf(num3,den3)
num4=[M1 D K]
den4=[M2.*M1 D.*M2 (K.*M2+K.*M1) D.*K]
sys4=tf(num4,den4)
subplot(2,2,3)
lsim(sys3,x,t)
grid on
subplot(2,2,4)

lsim(sys4,x,t)
grid on

Results:>>enter value of spring constant:


2
>>enter value of coefficient of viscous friction:
5
>>enter value of moment of inertia:
6
>>enter value of first mass:
10
>>enter value of second mass:
15
num1 =
2
den1 =
150

75

50

10

Transfer function:
2
-------------------------------150 s^4 + 75 s^3 + 50 s^2 + 10 s

num2 =
10

75

50

den2 =
150

10

Transfer function:
10 s^2 + 5 s + 2
-------------------------------150 s^4 + 75 s^3 + 50 s^2 + 10 s
num3 =
2
den3 =
150

75

50

10

Transfer function:
2
---------------------------150 s^3 + 75 s^2 + 50 s + 10

num4 =
10

75

50

den4 =
150

10

Transfer function:
10 s^2 + 5 s + 2
---------------------------150 s^3 + 75 s^2 + 50 s + 10

Linear Simulation Results

Linear Simulation Results

1.5

Amplitude

Amplitude

1.5
1

0.5

1
0.5
0

10

Time (seconds)
Linear Simulation Results

Linear Simulation Results


1

Amplitude

Amplitude

10

Time (seconds)

0.5

5
Time (seconds)

10

0.5

5
Time (seconds)

10

You might also like