%% Z1 (Step 4) - blocks in series and in parallel
% G1 = 2/(s+1), G2 = 3/(s+4). We look for K of the series and parallel connection.
% Run section by section: Ctrl+Enter.

%% 1) Two blocks
G1 = tf(2, [1 1])        % 2/(s+1)
G2 = tf(3, [1 4])        % 3/(s+4)
K1 = dcgain(G1)          % G1(0)
K2 = dcgain(G2)          % G2(0)

%% 2) Series: the signal goes through G1, then through G2 (SS-06 p.4)
Gs = G1*G2               % same as series(G1,G2)
Ks = dcgain(Gs)
pole(Gs)                 % poles
zero(Gs)                 % zeros

%% 3) Parallel: the same signal goes into both blocks, outputs are summed (SS-06 p.4)
Gp = G1 + G2             % same as parallel(G1,G2)
Ks_check = K1*K2         % rule for the gains: series = product
Kp_check = K1 + K2       % parallel = sum
Kpar = dcgain(Gp)
pole(Gp)
zero(Gp)

%% 4) Plot: both unit step responses
step(Gs, Gp); grid on
legend('seria G1*G2', 'rownolegle G1+G2')
