Вы находитесь на странице: 1из 8

4-1

% - - - - - - - - - - - - - United-step response ------------% ***** Enter the numerator and denominator of the transfer
% function *****
num = [0 0 25];
den = [1 4 25];
% ***** Enter the following step-response command *****
step(num,den)
% ***** Enter grid and title of the plot *****
grid
title (' 1Unit-Step Response of G(s) = 25/(s^2+4s+25)')
1Unit-Step Response of G(s) = 25/(s 2+4s+25)
1.4

1.2

Amplitude

0.8

0.6

0.4

0.2

0.5

1.5

2.5

Time (sec)

4-2
0];

Step Response
From: In(1)

From: In(2)

0.4

To: Out(1)

0.2

Amplitude

-0.2

-0.4
2

1.5

To: Out(2)

A =[-1
-1 ;6.5
B =[1 1;1 0];
C =[1
0;0 1];
D =[0
0;0
0];
step(A,B,C,D)

0.5

10

12 0
Time (sec)

10

12

4-3
% ----- Step-response curves for system defined in state space am-----% ***** In this program we plot step-response curves of a system
% having two inputs (ul and u2) and two outputs (yl and y2) *****
% ***** We shall first plot step-response curves when the input is
% u1. Then we shall plot step-response curves when the input is
%U2 *****
% ***** Enter matrices A, B, C, and D *****
A = [-1 -1;6.5 0];
B = [1 1;1 0];
C = [1 0;0 1 ];
D = [0 0;0 0];
% ***** To plot step-response curves when the input is ul, enter
% the command 'step(A,B,C,D,l)' *****
step (A,B,C,D)
grid
title ('Step-Response Plots: lnput = u l (u2 = 0)')
text(3.4, -0.06, 'Y1 ')
text(3.4, 1.4,'Y2')
% ***** Next, we shall plot step-response curves when the input
% is u2. Enter the command 'step(A,B,C,D,2)' *****
step(A,B,C,D,2)
grid
title ('Step-Response Plots: lnput = u2 (ul = 0)')
text(3,0.1, 4,'Y1 ')
text(2.8,1.1 ,'Y2')

Step-Response Plots: lnput = u2 (ul = 0)


0.3

To: Out(1)

0.2
0.1
0

Amplitude

-0.1
-0.2
2

To: Out(2)

1.5

Y2

0.5

Y1
0

6
Time (sec)

10

12

4-4
A = [0 1;-1 -1];
B = [0;1];
C = [1 0];
D = [0];
Impulse (A,B,C,D);
grid;
title('Unit-Impulse Response')
Unit-Impulse Response
0.6

0.5

Amplitude

0.4

0.3

0.2

0.1

-0.1

10

12

Time (sec)

4-5
num = [0 0 1 ];
den = [1 0.2 1 ];
impulse(num,den);
grid
title('Unit-Impulse Response of G(s) = l/(s^2 + 0.2s + 1)')

Unit-Impulse Response of G(s) = l/(s 2 + 0.2s + 1)


1
0.8
0.6

Amplitude

0.4
0.2
0
-0.2
-0.4
-0.6
-0.8

10

20

30
Time (sec)

40

50

60

4-6
num = [0 1 0];
den = [1 0.2 1 ] ;
step(num,den);
grid
title('Unit-Step Response of sG(s) = s/(s^2 + 0.2s + 1 )')

Unit-Step Response of sG(s) = s/(s 2 + 0.2s + 1 )


1
0.8
0.6

Amplitude

0.4
0.2
0
-0.2
-0.4
-0.6
-0.8

10

20

30

40

50

60

Time (sec)

4-7
%--------- Unit-ramp response --------------% ***** The unit-ramp response is obtained as the unit-step
% response of G(s)/s *****.
% ***** Enter the numerator and denominator of G(s)/s *****
num = [0 0 0 1 ];
den = [1 1 1 0];
% ***** Specify the computing time points (such as t = 0:0.1:7)
% and then enter step-response command: c = step(num,den,t) *****
t=0:0.1:7;
c=step(num,den,t);
% ***** In plotting the ramp-response curve, add the reference
% input to the plot. The reference input is t. Add to the
% argument of the plot command with the following: t,t,'-'. Thus
% the plot command becomes as follows: plot(t,c,'ol,t,t,'-'1 *****
%plot[t,c,'0',t,t,'-'];
plot(t,c,'o',t,t,'-')
% ***** Add grid, title, xlabel, and ylabel *****
grid
title('Unit-Ramp Response Curve for System G(s) = 1/(s^2 + s + 1)')
xlabel('t Sec')
ylabel('lnput and Output')

4-8
% - - - - - - - - - - - - - - - Unit-ramp response --------------% ***** The unit-ramp response is obtained by adding a new
% state variable x3. The dimension of the state equation
% is enlarged by one *****
% ***** Enter matrices A, B, C, and D of the original state
% equation and output equation *****
A= [0 1;-1 -1];
B = [0; 1];
C =[1 0];
D = [0];
% ***** Enter matrices AA, BB, CC, and DD of the new,
% enlarged state equation and output equation *****
AA = [A zeros(2,1 );C 0];
BB = [B;0];
CC = [0 0 1];
DD = [0];
% ***** Enter step-response command: [z,x,tl = step(AA,BB,CC,DD) *****
[z,x,t] = step(AA,BB,CC,DD);
% ***** In plotting x3 add the unit-ramp input t in the plot
% by entering the following command: plot(t,x3,'01,t,t,'-'1 *****
x3 = [0 0 1 ]*x';
plot(t,x3,'o',t,t,'-');
grid
title('Unit-Ramp Response')
xlabel('t Sec')
ylabel('lnput and Output')

4-9
%-------- Response to initial condition --------------% ***** System response to initial condition is converted to
% a unit-step response by modifying the numerator polynomial *****
% ***** Enter the numerator and denominator of the transfer
% function G(s) ***** I
num = [0.1 0.35 0];
den = [1 3 2];
% ***** Enter the following step-response command *****
step(num,den)
% ***** Enter grid and title oithe plot ***** I
grid
title('Response of Spring-Mass-Damper System to Initial Condition')

Response of Spring-Mass-Damper System to Initial Condition


0.12

0.1

Amplitude

0.08

0.06

0.04

0.02

4
Time (sec)

4-10
a=[0 1; -10 -5];
b=[2;1];
[x,z,t]=step(a,b,a,b);
x1=[1 0]*x';
x2=[0 1]*x';
plot(x1,'o',t,x2,'t')
grid
title('respuesta a condiciones iniciales')
xlabel('t seg')
ylabel('x1 x2')

4-11

4-12
>> %---enfoque en tiempo discreto--num = [0 10 100];
den=[1 10 100];
[a,b,c,d] = tf2ss(num,den);
[g,h] = c2d(a,b,0.001);
[num,den]= ss2tf(g,h,c,d);
%introdusca la entradas x1 x2
k1 = 0:537;
x1 = [2.452*(0.001*k1).^2];
k2 = 538:1500;
x2=[0.707*ones(size(k2))];
x=[x1 x2];
y= filter(num,den,x);
t=0:1500;
plot(t/1000,-y,'.',t/1000,-x,'-')
grid
title('enfoque en el tiempo discreto')
xlabel('t seg')
ylabel('entradax y salida y')
text(0.2, -0.54,'entrada x')
text(0.47, -0.25,'salida y')

Вам также может понравиться