You are on page 1of 15

Part-A

clc
clear all;
close all;

%1

Velocity = load('velocity.txt'); % ;load velocity values


dt=0.5; % sampling time
acceleration=[0;(Velocity(2:end)-Velocity(1:end-1))]/dt % acceleration
time=0:dt:((length(Velocity)/2)-0.5)% time vector

% Plotting velocity Vs Time Graph

plot(time,Velocity)
xlabel('time (s)')
ylabel('Velocity (m/s)')
grid on
title('time vs velocity')

figure

% Plotting Acceleration Vs Time Graph


plot(time,acceleration)
xlabel('time (s)')
ylabel('acceleration (m/s^2)')
grid on
title('time vs acceleration')

%2

p_2 = polyfit(time,Velocity,2); % seconnd order polynomial curve fitting

v_2 = polyval(p_2,time)';

a_2 = [0;(v_2(2:end)-v_2(1:end-1))]/dt % seconnd order polynomial acceleration

p_4 = polyfit(time,Velocity,4); % fourth order polynomial curve fitting

v_4 = polyval(p_4,time)';

a_4 = [0;(v_4(2:end)-v_4(1:end-1))]/dt % fourth order polynomial acceleration

figure

plot(time,Velocity,time,v_2,time,v_4)

legend('original','second order','4th order')

grid on
xlabel('time (s)')
ylabel('Velocity (m/s)')

figure

plot(time,acceleration,time,a_2,time,a_4)

legend('original','second order','4th order')

grid on
xlabel('time (s)')
ylabel('acceleration (m/s)')

%%

% 3.1
clc
clear all;
close all;

SID=[5,4,3,2,1,6,7]
T1=mean(SID)
T2=T1/5

phi1=deg2rad(sum(SID))
phi2=pi

t=0:0.01:3*T1

A=sum(SID)
B=A/6

for i=1:length(t)

y1(i)=A*sin((2*pi/T1)*t(i)-phi1);
y2(i)=B*cos((2*pi/T2)*t(i)+phi2);
y(i)=y1(i)-y2(i);

end
figure
plot(t,y1)
grid on
xlabel('time (s)')
ylabel('y1(t)')

figure
plot(t,y2)
grid on
xlabel('time (s)')
ylabel('y2(t)')

figure
plot(t,y)
grid on
xlabel('time (s)')
ylabel('y(t)')
% 3.2

for i=1:length(t)

if(y(i)>0 && y1(i)>0 && y2(i)>0)


c(i)=max(y);

elseif(y(i)<0 && y1(i)<0 && y2(i)<0)


c(i)=min(y);

else
c(i)=0;
end

end

figure
plot(t,y,t,y1,t,y2,t,c)
legend('y(t)','y1(t)','y2(t)','c(t)')
grid on
xlabel('time (s)')
ylabel('y(t), y1(t), y2(t), c(t)')

Results:
Part-B

2.1
Y (s)
Closed loop transfer function=
X (s)

Here, K, G1(s) and G2(s) are in series.

So
G(s)=K . G1 ( s ) .G 1 ( s )

G( s)=K
( 2
1
s +2 s +3 )( 2
1
s + 4 s +5 )
Y (s) G(s)
Closed looptransfer function= =
X (s) 1+G (s) H (s)

For unity feedback system, H(s)=0,

Y ( s) G(s )
T (s )= =
X (s) 1+G(s)

T (s )=
Y ( s)
=
( s + 2 s+3 s + 4 s+5 )
K
1
2 )( 1
2

( s +21s +3 )( s +41s +5 )
X (s)
1+ K 2 2

Y ( s) K
T (s )= =
X (s) (s ¿¿ 2+2 s+ 3)(s 2+ 4 s+5)+ K ¿

Y (s) K
T (s )= =
X ( s) s 4 +4 s 3+5 s2 +2 s 3 +8 s 2 +10 s+ 3 s 2+12 s +15+ K

The closed loop transfer function for the system is given as,

Y ( s) K
T (s )= =
X (s) s 4 +6 s 3 +16 s 2+ 22 s+15+ K
2.2

The characteristic equation is given as,

4 3 2
s + 6 s + 16 s + 22 s+15+ K =0

Applying RH criteria,

s4 1 16 15+K
s
3
6 22 0
s2 96−22 15+K 0
=12.33
6
s1 181.26−6 K 0
12.33
s0 15+K 0

For stable system,

181.26−6 K
>0∧15+ K >0
12.33

K <30.212∧K >−15

The system will be stable for range


−15< K <30.212

2.3

Simulink model of closed loop system

2.4

K=1 (system stable)


K=10(stable)
K=32 (unstable)

K=-20(unstble)

You might also like