I've been trying to solve an equation composed of matrices. MATLAB has run it for almost two hours now and nothing. It's supposed to multiply some 8x8 matrices and invert one 8x8 matrix. Should it take this long? I'm using an I7 8th gen 2.20 running at 4ghz, 16 gb and RTX 2060.
Code (the final line is where MATLAB is taking so long):
%% Modelagem do conversor SEPIC-Zeta em espaço de estados
%% Declarando variáveis simbólicas:
% Variáveis com o índice "_" são derivadas de primeira ordem.
% RL1, RL2, RL3 e RL4 são as resistências série dos indutores.
% RseC1, RseC2, RseC3 e RseC4 são as resistências série dos capacitores.
Vi = sym('Vi');
C1 = sym('C1');
C2 = sym('C2');
C3 = sym('C3');
C4 = sym('C4');
L1 = sym('L1');
L2 = sym('L2');
L3 = sym('L3');
L4 = sym('L4');
VC1 = sym('VC1');
VC2 = sym('VC2');
VC3 = sym('VC3');
VC4 = sym('VC4');
VC1_ = sym('VC1_');
VC2_ = sym('VC2_');
VC3_ = sym('VC3_');
VC4_ = sym('VC4_');
IL1 = sym('IL1');
IL2 = sym('IL2');
IL3 = sym('IL3');
IL4 = sym('IL4');
IL1_ = sym('IL1_');
IL2_ = sym('IL2_');
IL3_ = sym('IL3_');
IL4_ = sym('IL4_');
RL1 = sym('RL1');
RL2 = sym('RL2');
RL3 = sym('RL3');
RL4 = sym('RL4');
RseC1 = sym('RseC1');
RseC2 = sym('RseC2');
RseC3 = sym('RseC3');
RseC4 = sym('RseC4');
Ro = sym('Ro');
D = sym('D');
s = sym('s');
%% Determinando as matrizes de coeficientes do conversor em t = [0, DTs]:
% Equações LKT no conversor:
eqn11 = IL1_ - (-RL1*IL1 + Vi)/L1 == 0;
eqn21 = IL2_ - ((RseC1 - RL2)*IL2 - VC1)/L2 == 0;
eqn31 = IL3_ - (VC2 + (RseC2 - RL3)*IL3 + RseC2*IL4)/L3 == 0;
eqn41 = IL4_ - ((-VC3 + RseC2*C2*VC2_ - (RseC3 + RL4)*IL4 + Ro*C4*VC4_ + VC2)/L4) == 0;
eqn51 = VC1_ - (Vi - RL1*IL1 + L1*IL1_ + VC1 - L2*IL2_)/C1*(RseC1 - RL2) == 0;
eqn61 = VC2_ - (-RseC1*IL2 - VC1 - RL2*IL2 - L2*IL2_ + VC2 + L3*IL3_ + RL3*IL3)/(C2*RseC2) == 0;
eqn71 = VC3_ - (Ro*IL4 - Ro*C4*VC4_ - VC3 - L4*IL4_ + L3*IL3_ + RL3*IL3 - RL4*IL4)/(C3*RseC3) == 0;
eqn81 = VC4_ - (Ro*IL4 - VC4)/(C4*(RseC4 + Ro)) == 0;
% Solucionando o sistema de equações lineares:
sol1 = solve([eqn11, eqn21, eqn31, eqn41, eqn51, eqn61, eqn71, eqn81], [IL1_, IL2_, IL3_, IL4_, VC1_, VC2_, VC3_, VC4_]);
% Separando as matrizes A e B dos coeficientes:
system_A1 = [sol1.IL1_ == IL1_, sol1.IL2_ == IL2_, sol1.IL3_ == IL3_, sol1.IL4_ == IL4_,...
sol1.VC1_ == VC1_, sol1.VC2_ == VC2_, sol1.VC3_ == VC3_, sol1.VC4_ == VC4_];
vars1 = [ IL1, IL2, IL3, IL4, VC1, VC2, VC3, VC4 ];
vars21 = [ Vi ];
% Definindo as matrizes A1, B1, C1 e D1:
A1 = equationsToMatrix(system_A1,vars1);
B1 = equationsToMatrix(system_A1,vars21);
C1_ = [ 0; 0; 0; RseC4*Ro/(RseC4 + Ro); 0; 0; 0; Ro/(RseC4 + Ro) ];
D1 = 0;
%% Deterninando as matrizes dos coeficientes em t = [DTs, Ts]:
eqn12 = IL1_ - (-Vi + IL1*(RseC1 - RL1) + VC1 + RL2*IL2 + L2*IL2_)/L1 == 0;
eqn22 = IL2_ - (RseC2*IL1 + IL2*(-RL2 + RseC2) + VC2)/L2 == 0;
eqn32 = IL3_ - (-VC3 -RL3*IL3 - RseC3*IL3)/L3 == 0;
eqn42 = IL4_ - ((IL4*RL4 - Ro*IL4 - Ro*C4*VC4_)/L4) == 0;
eqn52 = VC1_ - (Vi - RseC1*IL1 - L1*IL1_ - VC1 + RL2*IL2 + L2*IL2_)/C1*(RseC1 + RseC2 - RL1) == 0;
eqn62 = VC2_ - (RL2*IL2 + L2*IL2_ - VC2)/(C2*RseC2) == 0;
eqn72 = VC3_ - (-Ro*IL4 - Ro*C4*VC4_ - VC3 + L4*IL4_ - L3*IL3_ + RL4*IL4)/(C3*(RL3 + RseC3)) == 0;
eqn82 = VC4_ - (Ro*IL4 - VC4)/(C4*(RseC4 - Ro)) == 0;
% Solucionando o sistema de equações lineares:
sol2 = solve([eqn12, eqn22, eqn32, eqn42, eqn52, eqn62, eqn72, eqn82], [IL1_, IL2_, IL3_, IL4_, VC1_, VC2_, VC3_, VC4_]);
% Separando as matrizes A e B dos coeficientes:
system_A2 = [sol2.IL1_ == IL1_, sol2.IL2_ == IL2_, sol2.IL3_ == IL3_, sol2.IL4_ == IL4_,...
sol2.VC1_ == VC1_, sol2.VC2_ == VC2_, sol2.VC3_ == VC3_, sol2.VC4_ == VC4_];
vars2 = [ IL1, IL2, IL3, IL4, VC1, VC2, VC3, VC4 ];
vars22 = [ Vi ];
% Definindo as matrizes A2, B2, C2 e D2:
A2 = equationsToMatrix(system_A2,vars2);
B2 = equationsToMatrix(system_A2,vars22);
C2_ = [ 0; 0; 0; RseC4*Ro/(RseC4 - Ro); 0; 0; 0; -Ro/(RseC4 - Ro) ];
D2 = 0;
%% Equacionamento para o espaço de estados médio:
A = simplify(A1*D + A2*(1-D));
B = simplify(B1*D + B2*(1-D));
C = simplify(C1_*D + C2_*(1-D));
D = simplify(D1*D + D2*(1-D));
X = simplify(-inv(A)*B*Vi);
I = eye(8);
Tp = C*inv(s*I - A)*((A1-A2)*X + (B1-B2)*Vi)+(C1-C2)*X;
Without understanding the math in detail I can see that it slows at line 108
X = simplify(-inv(A)*B*Vi);
rather than the last line, but I haven't been running it that long <1min. Try to utilizeA\b
instead ofinv(A)*b
which takes much more time.