Professional Documents
Culture Documents
26, 2010
%I = inv(A)*A;
if (nz == 1)
syms Y
R = 1/s;
X = ((I)^-1)*(xzero + (B*R));
Y = C*X + D*R;
x = ilaplace(X)
disp('(a.) State Variable, x1(t): ')
x1=x(1);
x1=simple(x1)
subplot(1,4,1)
ezplot (x2, [0 1])
axis tight
title('x1(t)')
%----
disp('(b.) State Variable, x2(t): ')
x2=x(2);
x2=simple(x2)
subplot(1,4,2)
ezplot (x2, [0 1])
axis tight
title('x2(t)')
%---
disp('(c.) State Variable, x3(t): ')
x3=x(3);
x3=simple(x3)
subplot(1,4,3)
ezplot (x3, [0 1])
axis tight
title('x3(t)')
1.1)
clc
syms s
nz = 0;
A = [-100 1 0; 0 -1.71 1; 0 0 0];
B= [0;0;1325];
C = [1 0 0];
D = 0;
a= eye(3) * s;
I = a - A;
clc
syms s
nz = 0;
A = [0 1 0 0 0; 0 0 1 0 0; 0 0 0 1 0; 0 0 0 0 1; -600 -118100 -33480 -3229
-130];
B= [0;0;0;0;10000];
C = [0.06 6.01 1 0 0];
D = 0;
a= eye(5) * s;
I = a - A;
clc
syms s
nz = 0;
A = [0 1 0; 0 0 1; -2 -104 -5];
B= [0;0;1];
C = [2 100 0];
D = 0;
a= eye(3) * s;
I = a - A;
clc
syms s
nz = 0;
A = [0 1 0 0; 0 0 1 0; 0 0 0 1; -750 -448 -94 -12];
B= [0;0;0;50];
C = [15 8 1 0];
D = 0;
a= eye(4) * s;
I = a - A;
display(' | 0 1 0 0||x1| | 0|| |')
display(' | 0 0 1 0||x2| + | 0||r(t)|')
display(' | 0 0 0 1||x3| | 0|| |')
display(' |-750 -448 -94 -12||x3| | 50|| |')
display(' ')
display(' y = |15 8 1 0||x1|')
display(' |x2|')
display(' |x3|')
1.5)
clc
syms s
nz = 0;
A = [- 20
-500; 1 0];
B = [1; 0];
C = [-0.002 -0.05];
D = [1/10000];
a= eye(2) * s;
I = a - A;
2.1)
clc
syms s
nz = 0;
A = [0 1 0; 0 0 1; 0 -171 -101.71];
B= [0;0;1];
C = [1325 0 0];
D = 0;
a= eye(3) * s;
I = a - A;
clc
syms s
nz = 0;
A = [-2 0 1; 0 -2 0; 0 0 -3];
B= [0;1;1];
C = [5 5 5];
D = 0;
a= eye(3) * s;
I = a - A;
clc
syms s
nz = 0;
A = [-2 1 0; 0 -2 0; 0 0 -3];
B= [0;1;1];
C = [5 0 5];
D = 0;
a= eye(3) * s;
I = a - A;
clc
syms s
nz = 0;
A = [-4 1 0; 0 0 1; 0 0 -3];
B= [0;2;1];
C = [1 0 0];
D = 0;
a= eye(3) * s;
I = a - A;
2.5)
clc
syms s
nz = 0;
A = [-4 1 0; 0 0 1; -5 0 -3];
B= [1;0;1];
C = [1 0 0];
D = 0;
a= eye(3) * s;
I = a - A;
3.1 ) clc
syms s
nz = 1;
A = [0 1 0; 0 0 1; -24 -26 -9];
B= [0;0;1];
C = [1 1 0];
D = 0;
a= eye(3) * s;
I = a - A;
xzero= [1;0;2];
clc
syms t s r R T X Y IR SR plot SV yn yes no
test = [t s];
disp('Note:enter u(t) in s-domain');
disp('Input Variable');
X = input ('Select Domain (Enter t or s): ');
test1 = isequal (X, test(1));
test2 = isequal (X, test(2));
test3 = test1 + test2;
while test3==0
'Input Variable'
X = input ('Select Domain (Enter t or s): ');
test1 = isequal (X, test(1));
test2 = isequal (X, test(2));
test3 = test1 + test2;
end
if X == t
r = input ('Enter R in time domain: ');
R = laplace (r)
T = C*((I)^-1)*B +D;
T = simple(T);
X = ((I)^-1)*(xzero+B*R);
X = simple(X);
x=ilaplace(X);
Y = C*x+D*R;
Y = simple(Y);
IR = ilaplace(T);
SR = ilaplace(T*(1/s));
display('Input')
pretty(R)
disp('Transfer Function')
pretty(T)
disp('State Variables')
pretty(x)
disp('Output')
pretty(Y)
disp('Impulse Response')
pretty(IR)
disp('Step Response')
pretty(SR)
plot = input('What do you want to plot?[R TF Y IR SR SV]: ')
if plot == R
ezplot (r, [0 20]);
elseif plot == TF
ezplot (T, [0 20]);
elseif plot == SV
disp('(a.) State Variable, x1(t): ')
x1=x(1);
x1=simple(x1)
subplot(1,3,1)
ezplot (x2, [0 5])
axis tight
title('x1(t)')
%----
disp('(b.) State Variable, x2(t): ')
x2=x(2);
x2=simple(x2)
subplot(1,3,2)
ezplot (x2, [0 5])
axis tight
title('x2(t)')
%---
disp('(c.) State Variable, x3(t): ')
x3=x(3);
x3=simple(x3)
subplot(1,3,3)
ezplot (x3, [0 5])
axis tight
title('x3(t)')
elseif plot == Y
ezplot (Y, [0 20]);
elseif plot == IR
ezplot (IR, [0 20]);
elseif plot == SR
ezplot (SR, [0 20]);
end
yn = input('Do you want to try again?[yes or no]: ');
if yn == yes;
activity4
elseif yn == no;
end
elseif X == s
R = input ('Enter R in s-domain: ')
T = C*((I)^-1)*B +D;
T = simple(T);
X = ((I)^-1)*(xzero+B*R);
X = simple(X);
x=ilaplace(X);
Y = C*X+D*R;
Y = simple(Y);
IR = ilaplace(T);
SR = ilaplace(T*(1/s));
display('Entered R in s-domain')
pretty(R)
display('Transfer Function')
pretty(T)
display('State Variables')
pretty(x)
display('Output equation')
pretty(Y)
display('Impulse Response')
pretty(IR)
display('Step Response')
pretty(SR)
plot = input('What do you want to plot?[R TF Y IR SR SV]: ')
if plot == R
ezplot (R, [0 20]);
elseif plot == TF
ezplot (T, [0 20]);
elseif plot == SV
disp('(a.) State Variable, x1(t): ')
x1=X(1);
x1=simple(x1)
subplot(1,3,1)
ezplot (x2, [0 5])
axis tight
title('x1(t)')
%----
disp('(b.) State Variable, x2(t): ')
x2=X(2);
x2=simple(x2)
subplot(1,3,2)
ezplot (x2, [0 5])
axis tight
title('x2(t)')
%---
disp('(c.) State Variable, x3(t): ')
x3=X(3);
x3=simple(x3)
subplot(1,3,3)
ezplot (x3, [0 5])
axis tight
title('x3(t)')
elseif plot == Y
ezplot (Y, [0 20]);
elseif plot == IR
ezplot (IR, [0 20]);
elseif plot == SR
ezplot (SR, [0 20]);
end
yn = input('Do you want to try again?[yes or no]: ');
if yn == yes;
activity4
elseif yn == no;
end
else
'Error'
end
SAMPLE OUTPUT FOR T DOMAIN
CONCLUSION: