echo on
close all
%--------------------------------------------------------------------------
% 3. gykorló feladat megoldása
%--------------------------------------------------------------------------
%
R = 1;
L = 200e-6;
KB = 2e-3;
KT = KB;
Bm = 10e-7;
Jm = 2e-7;
%
A = [-R/L -KB/L; KT/Jm -Bm/Jm];
B = [1/L 0; 0 -1/Jm];
C = eye(2);
D = zeros(2,2);
%
sys = ss(A,B,C,D);
%
%----------------- 
% a)
%-----------------
%
tf(sys)
%
%----------------- 
% b)
%----------------- 
%
[num1,den1]= ss2tf(A,B,C,D,1);
%
t = 0:.001:.25;
%
% Részlettörtekre bontás Y1(s):
[r,p,k] = residue(num1(1,:),[den1 0])
y1 = r(1)*exp(p(1)*t) + r(2)*exp(p(2)*t)+r(3)*exp(p(3)*t);
%
% ellenörzés
step(num1(1,:),den1);
hold;
plot(t,y1,'r--'); ylabel('y_1(t)');
hold off
%
% Részlettörtekre bontás Y2(s):
[r,p,k] = residue(num1(2,:),[den1 0])
y2 = r(1)*exp(p(1)*t) + r(2)*exp(p(2)*t)+r(3)*exp(p(3)*t);
%
% ellenörzés
figure
step(num1(2,:),den1);
hold;
plot(t,y2,'r--'); ylabel('y_2(t)');
hold off
%
%----------------- 
% c)
%----------------- 
%
figure
bode(num1(2,:),den1); grid;

echo off;