

Could it be that this is not a matrix, but just an expression that requires multiple lines to display?
Tom
(Dr. Thomas S. Ligon)
Frohnloher Str. 6a
81475 Muenchen
Germany
Tel. +49(89)74575075
From: 'nils Frank' via sympy <sy...@googlegroups.com>
Sent: Wednesday, March 12, 2025 9:51 AM
To: sympy <sy...@googlegroups.com>
Subject: [sympy] Extracting special parts of a matrix function
Hello everyone,
Hello everyone,
I have a function in the first row of a result matrix, and also in the second.
I'm separating the first row to write only the parts of it into a new matrix, for example, a multiplication by the second derivative of phi1.

Unfortunately, there's no result, just square brackets. Can anyone help? Thanks in advance.
Sympy Code:
#Testmatrix
C = d*sp.diff(phi1(t), t)+l*m*(2*g*sp.sin(phi1(t))+l*sp.sin(phi1(t)-phi2(t))*(sp.diff(phi2(t), t))**2+ l*sp.cos(phi1(t)-phi2(t))*sp.diff(phi2(t), t,t)+ 2*l*sp.diff(phi1(t), t,t))
D = sp.diff(phi2(t), t) + sp.diff(phi1(t), t)
Bw_Lag_Q_Test = sp.Matrix([[C], [D]])
Bw_Lag_Q_Test
erste_reihe_BW_Test = Bw_Lag_Q_Test.row(0)
erste_reihe_BW_Test
# Extract parts of erste_reihe_BW_Test
erste_reihe_BW_Test = Bw_Lag_Q_Test.row(0)
Extract_0 = [term.coeff(sp.diff(phi1(t), t,t)) for term in erste_reihe_BW if term.has(sp.diff(phi1(t), t,t))]
Extract_0

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/sympy/53ab1baa-d5ad-4c03-b02d-6a55b8358ba0n%40googlegroups.com.