# Buck-Boost Converter

state 1 matrices

A1: matrix([0, 0], [0, 0]);

B1: matrix([1/L, 0], [0, -1/c]);

C1: matrix([0, 1]);

D1: matrix([0, 0]);

state 2 matrices

A2: matrix([0, 1/L], [-1/c, 0]);

B2: matrix([0, 0], [0, -1/c]);

C2: matrix([0, 1]);

D2: matrix([0, 0]);

basic computation; keep it as it is

A: D0 * A1 + (1 - D0) * A2;

A: ratsimp(A);

B: D0 * B1 + (1 - D0) * B2;

B: ratsimp(B);

C: D0 * C1 + (1 - D0) * C2;

C: ratsimp(C);

D: D0 * D1 + (1 - D0) * D2;

D: ratsimp(D);

X0: matrix([Il], [Vc]);

U0: matrix([Vin], [Iout]);

E: (A1 - A2) . X0 + (B1 - B2) . U0;

E: ratsimp(E);

F: (C1 - C2) . X0 + (D1 - D2) . U0;

merging E and F; keep it as it is

B: addcol(B, E);

D: addcol(D, matrix([F]));

computing transfer functions; keep it as it is

S0: s * diagmatrix(2, 1) - A;

S: invert(S0);

S: ratsimp(S);

tox: S . B;

tox: ratsimp(tox);

toy: C . S . B + D;

toy: ratsimp(toy);

substituting values

tox1: ev(tox, D0 = 0.5, Vin = 10, Iout = -1, Il = 2, Vc = -10, L = 100e-6, c = 1e-3);

tox1: ratsimp(tox1);

tox1: factor(tox1);

tox2: ev(tox, D0 = 0.5, Vin = 10, Iout = -1, Il = 2, Vc = -10, L = 100e-6, c = 1e-3);

toy1: ev(toy, D0 = 0.5, Vin = 10, Iout = -1, Il = 2, Vc = -10, L = 100e-6, c = 1e-3);

toy1: ratsimp(toy1);

toy1: factor(toy1);