Professional Documents
Culture Documents
Corrected Matlab Assignment
Corrected Matlab Assignment
Solution 1:
Program:
prompt = 'Enter the value of k = ';
k = input(prompt);
num=[0 0 160*k 2880*k 2720*k];
den=[1 180 (1700+160*k) 2880*k 2720*k];
step(num,den);
grid;
title('Step Response');
sys = tf([0 0 160*k 2880*k 2720*k],[1 180 (1700+160*k) 2880*k 2720*k]);
S = stepinfo(sys,'RiseTimeLimits',[0.05,0.95])
Result:
S=
RiseTime: 0.3419
SettlingTime: 2.4192
SettlingMin: 0.9543
SettlingMax: 1.1508
Overshoot: 15.0815
Undershoot: 0
Peak: 1.1508
PeakTime: 0.7539
Output plot is attached below:
Step Response
1.4
1.2
Amplitude
0.8
0.6
0.4
0.2
0.5
1.5
2
Time (sec)
2.5
3.5
Ans 2:
a)
num=[0 0 10];
den=[1 2 10];
step(num,den);
grid;
title('Step Response');
b)
num=[0 0 10];
den=[1 2 10];
impulse(num,den);
grid;
title('Impulse Response');
c)
num=[0 10 0];
den=[1 2 10];
t=0:0.1:7;
c=step(num,den,t);
plot(t,c,'o',t,t,'--');
grid;
title('Ramp Response');
Step Response
1.4
1.2
Amplitude
0.8
0.6
0.4
0.2
3
Time (sec)
Impulse Response
2.5
Amplitude
1.5
0.5
-0.5
-1
4
Time (sec)
Ramp Response
7
-1
Ans 3:
a)
A=[-1 -0.5; 1 0];
B=[0.5; 0];
C=[1 0];
D=[0];
step(A,B,C,D);
grid;
title('Step Response');
b)
A=[-1 -0.5; 1 0];
B=[0.5; 0];
C=[1 0];
D=[0];
impulse (A,B,C,D);
grid;
title('Impulse Response');
c)
A=[-1 -0.5; 1 0];
B=[0.5; 0];
C=[1 0];
D=[0];
[n,e]=ss2tf(A,B,C,D);
t=0:0.1:7;
c=step(n,e,t);
plot(t,c,'o',t,t,'--');
grid;
title('Ramp Response');
Step Response
0.35
0.3
0.25
Amplitude
0.2
0.15
0.1
0.05
-0.05
8
Time (sec)
10
12
14
Impulse Response
0.5
0.4
Amplitude
0.3
0.2
0.1
-0.1
-0.2
5
Time (sec)
10
Ramp Response
7
-1