So im trying to add two matrixes together in sympy from a 2x2 matrix to a 3x3 matrix and im not really sure how to do it! What i want to achieve is this: Wanted Result
By adding together: K1 and K2. Beacuse they have different places in the total matrix. What i have done:
import sympy as sy
E,t = sy.symbols("E,t")
K1 = sy.Matrix([[17.5*E*t,-17.5*E*t],[-17.5*E*t,17.5*E*t]])
K2 = sy.Matrix([[12.5*E*t,-12.5*E*t],[-12.5*E*t,12.5*E*t]])
K_Total_Rad_1 = []
K_Total_Rad_2_1 = []
K_Total_Rad_2_2 = []
K_Total_Rad_3 = []
for i in range(len(K1)-2):
K_Total_Rad_1.append(K1[i])
for i in range(len(K2)-2):
K_Total_Rad_2_1.append(K1[i+2])
for i in range(len(K2)-2):
K_Total_Rad_2_2.append(K2[i])
for i in range(len(K2)-2):
K_Total_Rad_3.append(K2[i-2])
K_Total = sy.Matrix([K_Total_Rad_1, K_Total_Rad_2_2, K_Total_Rad_3])
K_Total
I Obviosly know that the error here is with defining the Matrix dimentions but i dont know how to do this here in python. Hope someone can help