MGMatrixExample.html (MotionGenesis input/output).
(1) % MotionGenesis file: MGMatrixExample.txt
(2) zeroMat23 = GetZeroMatrix( 2, 3 )
-> (3) zeroMat23 = [0, 0, 0; 0, 0, 0]
(4) identity33 = GetIdentityMatrix( 3, 3 )
-> (5) identity33 = [1, 0, 0; 0, 1, 0; 0, 0, 1]
(6) M = [1, 2; 3, sin(t)] % 2 x 2 matrix.
-> (7) M = [1, 2; 3, sin(t)]
(8) add = M + M
-> (9) add = [2, 4; 6, 2*sin(t)]
(10) mult5 = 5 * M
-> (11) mult5 = [5, 10; 15, 5*sin(t)]
(12) multM = M * M
-> (13) multM = [7, 2 + 2*sin(t); 3 + 3*sin(t), 6 + sin(t)^2]
(14) divide = M / 2
-> (15) divide = [0.5, 1; 1.5, 0.5*sin(t)]
(16) transpose = GetTranspose( M )
-> (17) transpose = [1, 3; 2, sin(t)]
(18) det = GetDeterminant( M )
-> (19) det = -6 + sin(t)
(20) trace = GetTrace( M )
-> (21) trace = 1 + sin(t)
(22) derivative = Dt( M )
-> (23) derivative = [0, 0; 0, cos(t)]
(24) inv = GetInverse( M )
-> (25) inv[1,1] = sin(t)/(-6+sin(t))
-> (26) inv[1,2] = -2/(-6+sin(t))
-> (27) inv[2,1] = -3/(-6+sin(t))
-> (28) inv[2,2] = 1/(-6+sin(t))
(29) eigValues = GetEigen( M )
-> (30) eigValues[1] = 0.5 + 0.5*sin(t) - 0.5*sqrt(24+(1+sin(t))^2-4*sin(t))
-> (31) eigValues[2] = 0.5 + 0.5*sin(t) + 0.5*sqrt(24+(1+sin(t))^2-4*sin(t))
(32) element12 = M[ 1, 2 ] % Element in 1st row, 2nd column.
-> (33) element12 = 2
(34) element12 = GetElement( M, 1, 2 )
-> (35) element12 = 2
(36) row2 = GetRow( M, 2 ) % Extract row 2 of M.
-> (37) row2 = [3, sin(t)]
(38) col2 = GetCol( M, 2 ) % Extract column 2 of M.
-> (39) col2 = [2; sin(t)]
(40) extractRows = GetRow( M, 2, 1 ) % Extract rows 2 and 1 of M.
-> (41) extractRows = [3, sin(t); 1, 2]
(42) colTwice = GetColumns( M, 2, 2 ) % Extract column 2 of M twice.
-> (43) colTwice = [2, 2; sin(t), sin(t)]
(44) MM = [ M, M ] % 2 x 4 matrix.
-> (45) MM = [1, 2, 1, 2; 3, sin(t), 3, sin(t)]
(46) Metc = [ M, 7*M, GetIdentityMatrix(2,2) ]
-> (47) Metc = [1, 2, 7, 14, 1, 0; 3, sin(t), 21, 7*sin(t), 0, 1]
(48) extract = Metc[ 1:2, 3:6 ] % Extract rows 1-2 and columns 3-6.
-> (49) extract = [7, 14, 1, 0; 21, 7*sin(t), 0, 1]
Saved by Motion Genesis LLC. MotionGenesis 6.4 Professional. Command names and syntax: Copyright (c) 2024 Motion Genesis LLC. All rights reserved.