1
$\begingroup$

I have got the solution of the matrix system and get the solution using LinearSolve, and now I want to use MATLAB to see whether it can generate the same solution, so now the question is how to convert the Mathematica matrix to MATLAB or save as .mat files?

AA={{0.681598, 0, 0, 0, 0, -0.681598, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 1.46714, 0, 0, 0, 0, -1.46714, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0.82559, 0, 0, 0, 
  0, -0.82559, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 1.21126, 0, 0, 0, 0, -1.21126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0}, {0, 0, 1., 0, 0, 0, 0, -1., 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1., 0, 0, 0, 0, -1., 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0.82559, 0, 0,
   0, 0, -0.82559, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 1.21126, 0, 0, 0, 0, -1.21126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0.681598, 0, 0, 0, 0, -0.681598, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.46714, 0, 0,
   0, 0, -1.46714, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0}, {24459.9, 0, 0, 0, 0, -2.44599*10^7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -52649.9, 0, 0, 0, 0, 5.26499*10^7, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 14813.6,
   0, 0, 0, 0, -1.48136*10^7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, -21733.6, 0, 0, 0, 0, 2.17336*10^7, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 
  14813.6, 0, 0, 0, 0, -1.48136*10^7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, -21733.6, 0, 0, 0, 0, 2.17336*10^7, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 24459.9, 0, 
  0, 0, 0, -2.44599*10^7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, -52649.9, 0, 0, 0, 0, 5.26499*10^7, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0.544007, 0, 0, 0, 
  0, -0.544007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 1.83821, 0, 0, 0, 0, -1.83821, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0}, {0, 0, 0, 0, 0, 0, 0.737568, 0, 0, 0, 0, -0.737568, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.35581, 0, 0, 0,
   0, -1.35581, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 
  0, 0, 0, 1., 0, 0, 0, 0, -1., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 1., 0, 0, 0, 0, -1., 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0.737568, 0, 0, 0, 0, -0.737568, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.35581, 0,
   0, 0, 0, -1.35581, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0.544007, 0, 0, 0, 0, -0.544007, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.83821, 0, 0, 0, 0, -1.83821, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1.95223*10^7, 0, 0, 
  0, 0, -1.95223*10^7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, -6.59663*10^7, 0, 0, 0, 0, 6.59663*10^7, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 1.32342*10^7, 0, 0, 0, 
  0, -1.32342*10^7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, -2.43273*10^7, 0, 0, 0, 0, 2.43273*10^7, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 
  1.32342*10^7, 0, 0, 0, 0, -1.32342*10^7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2.43273*10^7, 0, 0, 0, 0, 
  2.43273*10^7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 
  0, 0, 0, 1.95223*10^7, 0, 0, 0, 0, -1.95223*10^7, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -6.59663*10^7, 0, 0, 0, 0, 
  6.59663*10^7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0.527102, 0, 0, 0, 0, -0.902105, -0.0381047, 
  1.97961*10^-18, 0.032252, -0.0134366, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 1.89717, 0, 0, 0, 0, -1.11357, 
  0.05251, -1.1669*10^-18, -0.0448925, 0.0203351, 0, 0, 0, 0, 0}, {0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.726018, 0, 0, 
  0, -0.0986374, -0.829503, 2.94472*10^-17, -0.0104496, -0.0199249, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.37738, 0, 0, 0, 
  0.131642, -1.21095, -3.50757*10^-17, 0.0193318, 0.0226718, 0, 0, 0, 
  0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1., 0, 0, -0.0349483, 
  0.0685689, -1., 0.0685689, -0.0349483, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 1., 0, 0, 
  0.0487879, -0.0819742, -1., -0.0819742, 0.0487879, 0, 0, 0, 0, 
  0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.726018, 
  0, -0.0199249, -0.0104496, 1.28285*10^-17, -0.829503, -0.0986374, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.37738, 0, 
  0.0226718, 0.0193318, -1.44857*10^-17, -1.21095, 0.131642, 0, 0, 0, 
  0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0.527102, -0.0134366, 0.032252, 
  3.3025*10^-18, -0.0381047, -0.902105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 1.89717, 
  0.0203351, -0.0448925, -4.28565*10^-18, 0.05251, -1.11357, 0, 0, 0, 
  0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.89157*10^7, 0, 0, 0, 
  0, -4.80815*10^6, 3.94552*10^6, 5.01417*10^-10, -651517., -421070., 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -6.80819*10^7, 0, 0, 0,
   0, 7.14445*10^6, -6.39465*10^6, -7.75403*10^-10, 1.62243*10^6, 
  272901., 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  1.3027*10^7, 0, 0, 0, 3.94552*10^6, -5.17264*10^6, -6.08506*10^-10, 
  2.81443*10^6, -651517., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, -2.47143*10^7, 0, 0, 0, -6.39465*10^6, 8.32061*10^6, 
  9.22064*10^-10, -4.91195*10^6, 1.62243*10^6, 0, 0, 0, 0, 0}, {0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  7.68341*10^-9, -5.12227*10^-9, 1.23481*10^-10, 2.79397*10^-9, 
  1.10012*10^-8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, -9.77889*10^-9, 
  7.91624*10^-9, -1.23481*10^-10, -3.95812*10^-9, -1.28639*10^-8, 0, 
  0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.3027*10^7, 
  0, -651517., 2.81443*10^6, -2.42715*10^-10, -5.17264*10^6, 
  3.94552*10^6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, -2.47143*10^7, 0, 1.62243*10^6, -4.91195*10^6, 1.46968*10^-10, 
  8.32061*10^6, -6.39465*10^6, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 1.89157*10^7, -421070., -651517., 
  4.57265*10^-10, 3.94552*10^6, -4.80815*10^6, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -6.80819*10^7, 272901., 
  1.62243*10^6, -4.80592*10^-10, -6.39465*10^6, 7.14445*10^6, 0, 0, 0,
   0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.886273, 
  0.043591, -2.39217*10^-18, -0.0368646, 0.0152343, -0.781879, 
  0.0567719, 1.78127*10^-17, -0.0244502, -0.0138963, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 1.13544, -0.0635594, 1.26461*10^-18, 
  0.0543889, -0.0248018, -1.30933, -0.0962959, 4.51115*10^-18, 
  0.0442529, 0.0433231}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0.113137, 0.803033, -3.41274*10^-17, 0.0116013, 0.0231257, 
  0.209736, -0.783976, 3.06846*10^-17, -0.00228765, -0.0664327, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.158865, 1.25301, 
  4.19225*10^-17, -0.0239344, -0.026909, -0.354315, -1.30513, \
-1.92218*10^-17, 0.0238072, 0.123574}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0.0398838, -0.0794265, 1., -0.0794265, 
  0.0398838, -0.0204021, 0.174613, -1., 0.174613, -0.0204021, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.0590519, 0.0979871, 1., 
  0.0979871, -0.0590519, -0.014461, -0.222673, -1., -0.222673, \
-0.014461}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0231257, 
  0.0116013, -1.49261*10^-17, 0.803033, 
  0.113137, -0.0664327, -0.00228765, -9.15279*10^-17, -0.783976, 
  0.209736, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, -0.026909, -0.0239344, 1.72177*10^-17, 1.25301, -0.158865, 
  0.123574, 0.0238072, -2.22052*10^-17, -1.30513, -0.354315}, {0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0.0152343, -0.0368646, -3.79996*10^-18, 0.043591, 
  0.886273, -0.0138963, -0.0244502, 1.00555*10^-16, 
  0.0567719, -0.781879, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, -0.0248018, 0.0543889, 5.16276*10^-18, -0.0635594, 1.13544, 
  0.0433231, 0.0442529, -1.71668*10^-17, -0.0962959, -1.30933}, {0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  4.64675*10^6, -3.78095*10^6, -4.82725*10^-10, 592772., 
  424926., -340251., 160852., -5.49545*10^-11, -129052., 204067., 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7.403*10^6, 6.67194*10^6,
   8.06008*10^-10, -1.74152*10^6, -247425., 431093., -180426., 
  1.6481*10^-11, 145890., -229877.}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, -3.78095*10^6, 4.96241*10^6, 
  5.87177*10^-10, -2.67944*10^6, 592772., 160852., -101539., 
  6.36591*10^-11, 72933.6, -129052., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 6.67194*10^6, -8.67901*10^6, -9.57219*10^-10, 
  5.15799*10^6, -1.74152*10^6, -180426., 
  126839., -3.86899*10^-11, -83747.7, 145890.}, {0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, -6.98492*10^-9, 
  4.19095*10^-9, -1.23481*10^-10, -3.20142*10^-9, -1.11759*10^-8, \
-4.83124*10^-9, 2.2701*10^-9, -6.14733*10^-11, -3.95812*10^-9, 
  2.09548*10^-9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  9.77889*10^-9, -6.51926*10^-9, 1.23481*10^-10, 4.19095*10^-9, 
  1.29221*10^-8, 4.88944*10^-9, -2.96859*10^-9, 6.14733*10^-11, 
  6.98492*10^-9, 1.16415*10^-9}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 592772., -2.67944*10^6, 2.48436*10^-10, 
  4.96241*10^6, -3.78095*10^6, -129052., 72933.6, 
  5.17967*10^-11, -101539., 160852., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, -1.74152*10^6, 
  5.15799*10^6, -1.35105*10^-10, -8.67901*10^6, 6.67194*10^6, 
  145890., -83747.7, -8.18553*10^-11, 126839., -180426.}, {0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 424926., 
  592772., -4.54748*10^-10, -3.78095*10^6, 4.64675*10^6, 
  204067., -129052., -3.20825*10^-11, 160852., -340251., 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -247425., -1.74152*10^6, 
  4.81898*10^-10, 6.67194*10^6, -7.403*10^6, -229877., 145890., 
  9.28378*10^-11, -180426., 431093.}, {1., 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1., 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1., 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  1., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0}, {0, 0, 1., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 1., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1., 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 1., 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1., 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0. + 27.725 I,
   0. - 4.06836 I, 0. - 3.0604*10^-16 I, 0. + 1.71575 I, 
  0. + 0.558657 I, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0. + 81.0898 I, 0. + 12.2025 I, 0. - 4.88115*10^-16 I, 
  0. - 5.87267 I, 0. - 6.85412 I}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0. - 7.52439 I, 0. + 13.9334 I, 
  0. - 1.01465*10^-15 I, 0. - 0.13776 I, 0. + 2.30907 I, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0. + 22.3807 I, 
  0. + 40.2481 I, 0. + 9.40814*10^-16 I, 0. - 2.19887 I, 
  0. - 8.34859 I}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0. - 2.30907 I, 0. + 0.13776 I, 
  0. - 1.73896*10^-15 I, 0. - 13.9334 I, 0. + 7.52439 I, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0. + 8.34859 I, 
  0. + 2.19887 I, 0. - 1.37134*10^-15 I, 0. - 40.2481 I, 
  0. - 22.3807 I}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0. - 0.558657 I, 0. - 1.71575 I, 0. + 4.38062*10^-15 I, 
  0. + 4.06836 I, 0. - 27.725 I, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0. + 6.85412 I, 0. + 5.87267 I, 
  0. - 1.95554*10^-15 I, 0. - 12.2025 I, 0. - 81.0898 I}};


bb={0., 0.807353 + 0.127872 I, 0., 
 0.807353 - 0.127872 I, 0., 0., 0., 0., 0., 0., 0., -0.807353 - 
  0.127872 I, 0., -0.807353 + 
  0.127872 I, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., \
0., 0., -0.00173224 - 0.026907 I, -0.0382822 - 0.0843441 I, 
 4.76335*10^-18 - 5.75795*10^-17 I, -0.0382822 + 
  0.0843441 I, -0.00173224 + 
  0.026907 I, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -1.21339 + 
  0.0781167 I, -1.90178 + 0.863183 I, 0., -1.90178 - 
  0.863183 I, -1.21339 - 0.0781167 I};

But if using

<< ToMatlab.m
ToMatlab[AA]

We get:

[0.681598E0,0,0,0,0,(-0.681598E0),0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, ...
\

  0,0,0,0.146714E1,0,0,0,0,(-0.146714E1),0,0,0,0,0,0,0,0,0,0,0,0,0, ...
\

Which is really not what we want.

By the way, will the accuracy lose when converting the matrix? And maybe MATLAB will not give the same solution as Mathematica.

Now I want to use MATLAB to see whether it can generate the same solution, so how to convert the Mathematica matrix to MATLAB or save as .mat files?

$\endgroup$
5
  • 2
    $\begingroup$ Can Matlab read a CSV? Export in a format both can handle $\endgroup$
    – I.M.
    Jul 10, 2023 at 13:36
  • 3
    $\begingroup$ No need for "ToMatlab`" Just do Export["filename.mat",AA]. $\endgroup$ Jul 10, 2023 at 14:41
  • 1
    $\begingroup$ "By the way, will the accuracy lose when converting the matrix? " Yes an no. Matlab stores everything in double precision floating point number, so does the mat format. When Mathematica exports to .mat it converts all numbers to doubles (if possible). In particular it converts exact integers to doubles. But since some of the matrix entries are already doubles, no actual precision will be lost. $\endgroup$ Jul 10, 2023 at 17:10
  • $\begingroup$ @HenrikSchumacher, well received and thank you very much! $\endgroup$
    – fhrl
    Jul 11, 2023 at 3:43
  • 1
    $\begingroup$ I would instead bring the MATLAB matrix to Mathematica using MATLink and then use ExpressionLineDiff to compare both. $\endgroup$ Jul 11, 2023 at 12:49

1 Answer 1

0
$\begingroup$

It is useful to use

Export["filename.mat",AA]

But after that, we have to use

AA=load("AA.mat").Expression1

rather than

AA=load("AA.mat")

to load the matrix into MATLAB.

$\endgroup$
1
  • $\begingroup$ You can export the matrix under a different name with Export["AA.mat", "x" -> AA]. Also, it is enough to do load("AA.mat") and the variable from the file will be added to MATLAB's workspace. $\endgroup$
    – rafalc
    Jul 17, 2023 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.