Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

Filter by
Sorted by
Tagged with
1
vote
0answers
49 views

Print 4x4x4x4 tensor as 4x4 matrix of 4x4 matrices [closed]

I'd like to print the LeviCivitaTensor[4] tensor as 4x4 block matrix of 4x4 matrices The following code works to display the LeviCivitaTensor[3] tensor as a 3x1 vector of 3x3 matrices. ...
2
votes
1answer
63 views

How to import a part of an Excel file?

I'm trying to import a part of an excel, the column 20 and the row between 6-59 in this column. I tried : tab = Import[ "file.xlsx"]; time = tab[[20, 6 ;; 59]] ...
0
votes
2answers
76 views

How to get eigenvectors of a 4x4 matrix? [closed]

MatrixForm[m = {{2, 9, 0}, {3, 8, 9}, {3, 9, 1}}] Eigensystem[m] I am facing problem in finding eigenvectors using ...
10
votes
3answers
533 views

Optimising subdiagonal shift matrix generation time

I want a square matrix $A$ such that $$A_{i,i-1} = 1 \ \forall i\\ A_{i,j} = 0 \text{ for } \ j \ne i-1$$ I have tried ...
1
vote
2answers
39 views

NSolve cannot find solution to system of trig equations

I was making a program to convert a rotation matrix to a set of euler angles. I wanted to do this for any valid rotation order that the euler angles were made with, and I did not want to do it the ...
4
votes
5answers
159 views

Generate random non-zero “island” in matrix of zeros

I'm trying to write a code which will generate a 3 dimensional array of 0s, then pick some random location in the array, and subsequently expand contiguously to random neighboring sites until a set of ...
0
votes
2answers
43 views

Mathematica doesn't evaluate/simplify arithmetic expression in its output [closed]

I have two matrices, A := {{1, 2, -4}, {2, -2, -2}, {-4, -2, 1}} and ...
0
votes
0answers
18 views

Solve, store, and access eigenvalues and eigenstates of M[x,y], for various points {x,y}

I'm interested in solving a position dependent eigenvalue problem for matrix M[x,y], where {x,y} is some discretized set of points. I may need to access the eigenstates and eigenvalues multiple times ...
0
votes
0answers
43 views

How to export a multidimensional array in which each element is also an array?

I have a {15,5,2} dimensional array and each element is itself a {14,16} dimensional array. When I export/import my file as an excel file I get a {15,,5,2} dimensional array but with {} dimension for ...
1
vote
0answers
34 views

Bug in SmithDecomposition?

While trying to calculate the SmithDecomposition of an integer 293x329 matrix with less than 3000 non-zero elements in the range -4 to 3 several errors occur, none of them which seem to make any sense ...
3
votes
1answer
45 views

How can I arrange the columns of a transposed matrix in an special way?

How can I do the below process on a matrix in a straightforward way: Firstly, change the rows with columns and secondly, arrange the columns of the matrix in a way that for a N*N matrix, the first ...
0
votes
1answer
41 views

I am asserting a variable in Mathematica as Real yet it is not implementing it!

Element[\[Theta], Reals]; Ga = g; Gb = g*Exp[I*\[Theta]]; {{Conjugate[Gb], Ga}, {Ga, Gb}} I have a code as such for a matrix as given above. as ...
0
votes
1answer
53 views

Time used by Mathematica to calculate tridiagonal matrix

I have a question. I need to find the eigenvalues and eigenvectors of a tridiagonal matrix of size NxN. Can you tell me how much time does Mathematica need to do that in minutes? for Size N ...
2
votes
1answer
40 views

How to assemble matrices (updated)?

I wish to update my question. Based off the answer provided, I tried ArrayFlatten for the following: 𝐴 is a 4x2 matrix, 𝐵 is a 4x4 matrix, and 𝐶 is a 4x6 matrix. I tried this to construct a 4x12 ...
1
vote
2answers
53 views

How to assemble matrices?

I'm a beginner in Mathematica and have a very basic question. Suppose I have made the following matrices (4x4). $$A,B,C,D,$$ and I want to make the larger matrix $$\begin{bmatrix} A & B \\ C &...
1
vote
1answer
69 views

How to interchange columns of a matrix? [duplicate]

Suppose I have a matrix M={{1,2,3},{4,5,6},{7,8,9}}//MatrixForm What code do I write to interchange columns and make it into ...
1
vote
2answers
53 views

Checking that a certain function is equal to zero for all $|i-j|>1$

Suppose s[i] and e[i] are $m\times m$ matrices, where $i=1,\ldots, n$. I would like to check for all $|i-j|>1$, ...
0
votes
0answers
20 views

Error while defining custom matrix function

I'm trying to define a custom matrix Ry with a parameter x, in Mathematica. ...
2
votes
1answer
79 views

Outer (dyadic) product between vectors of the same index in two lists

I have two lists of vectors and I want to take the outer product between elements in the lists of the same index. Using either Outer or TensorProduct works for e.g. the first two indices: ...
2
votes
1answer
52 views

Code for the elementary $m\times m$ matrix $E_{ij}$

Let $E_{ij}$ be an $m\times m$ matrix with a $1$ in the $(i,j)$-entry and zero otherwise. DiagonalMatrix[{1},j,m] will put a $1$ in the first row along the $j$-th ...
0
votes
1answer
51 views

Why is this Mathematica code unable to solve for the real parameter set?

I tried using Bill's code for obtaining the parameters $\theta, \phi$ and $\lambda$ for the unitary $$Z=\begin{pmatrix}\frac{1}{\sqrt 2} & \frac{i}{\sqrt 2} \\ \frac{i}{\sqrt 2} & \frac{1}{\...
2
votes
2answers
80 views

Solving for three parameters from a matrix equation and storing them in separate variables

Say I have a matrix $$ Z=\begin{pmatrix}-\frac{1}{\sqrt 2} & \frac{i}{\sqrt 2} \\ \frac{i}{\sqrt 2} & -\frac{1}{\sqrt 2} \end{pmatrix} $$ and another matrix $$ U(\theta, \phi, \lambda) = ...
1
vote
1answer
79 views

How to compile properly for performance tuning

I have a question about how to compile functions properly for performance tuning. Currently, I am trying to solve an eigenvalue problem of a large matrix. Initially I just used the conventional ...
1
vote
1answer
82 views

How to speed up the calculation of a multi-dimension matrix involving symbolic integral?

The following program succeeds in getting matrix CC, but it takes time badly, especially in the case varNumber becomes larger just as the following ...
0
votes
1answer
46 views

Evaluation Control for Equation Input to NDSolve

I am trying to numerically integrate a system of equations using NDSolve and am having issues with symbolic matrix inversion taking a long time. The actual system is much more complicated, but I have ...
3
votes
2answers
177 views

Condition on all eigenvalues of a matrix

I am going to help Mathematica to satisfy the condition: If all elements of a matrix's eigenvalues are different from zero, then print "ok" For ...
0
votes
1answer
42 views

Not able to multiply the output of the code below

It is the output of the code given below ...
0
votes
1answer
22 views

Computing Jacobian of $T(z,t) = (zt, z(1-t))$ [closed]

For $T: \mathbb{R}^2 \rightarrow \mathbb{R}^2$ s.t. $T(z,t) = (tz, (1-t)z)$, how does one use Mathematica to compute the Jacobian matrix of $T$ (to then compute its determinant)? Suppose $(z,t)$ are ...
1
vote
1answer
66 views

How to join two matrix with different dimensions?

I have two matrices with different dimensions I want to join them together in one matrix. for example, I have two lists of diseases associated with their symptoms in both matrix, what I want is to ...
2
votes
2answers
83 views

Is there an efficient way to fill in the elements of a matrix as m11,m12…etc?

I want to autofill the elements of a matrix (or list) by m11, m12, etc. I am able to autofill using ...
0
votes
1answer
58 views

Solve Set of Linear Equations (Analytic)

I have at a hand a set of linear equations of the form M*x=y (matrix form) M_ij * x_j = y_i where i = 1,...,N (in components) where M is symmetric, and all its elements are positive. Further, ...
2
votes
0answers
46 views

How to calculate a projection of x,y,z data to x any y plane?

I have a List containing x,y,z data, which I can plot nicely in a ListContourPlot: ...
1
vote
1answer
72 views

How do I extract the matrix from an density matrix equation?

I have a density matrix equation and I wish to put it in the form of a matrix. For example, if I have: $$\rho =Ax_{1}x_{1}+Bx_{1}x_{2}+Cx_{2}x_{1}+Dx_{2}x_{2}$$ Copy-and-paste version ...
0
votes
1answer
44 views

Matrix definition using some rules for the elements

I'm gonna produce a matrix in which the matrix elements obey the following rules $\left<n \right|M \left| m \right> = m^2 \delta_{m,n},$ $\left<m \pm 2 \right|M \left| m \right> = (1-m) ...
1
vote
1answer
62 views

Why doesn't the matrix rank decrease in this case?

Consider the square matrix $M(k)$ of dimension 6 $ M(k) = \frac{1}{\sqrt{2}}\begin{bmatrix} 0 & 0 & 1 & i & 0 & 0\\ 0 & 0 & 0 & 0 & ie^{-ik} & e^{-ik} \\ 0 &...
5
votes
4answers
399 views

Looking for a simple way to manipulate one column of a matrix

Given {{a, b}, {c, d}} I want to get {{c, b}, {a, d}} with one simple expression. Is this possible?
1
vote
2answers
82 views

Selecting matrices based on existence of unique column and row of all equal terms

So, I have a list of lists of lists such as the following: {{{4}}, {{7, 7}, {7, 7}}, {{5, 5}, {6, 6}}, {{2, 1}, {1, 1}}} Interpreting the elements of this list ...
0
votes
0answers
27 views

Relation between matrices

Maybe this is not a usual question for this forum... I have the following two matrices, Ds and Dss, respectively: ...
1
vote
2answers
60 views

Matrix with simplified EngineeringForm

I have the following numerical matrix: Ds={{0.0002773500981126146, -0.0002773500981126146},{0.0005547001962252292, -0.0002773500981126146}} I would like to ...
0
votes
1answer
56 views

Strange result of MatrixFunction

Let us consider the sum of the matrix series m = 2; n = 3; Sum[MatrixPower[{{1, 2}, {3, 4}}, m + k*n]/(m + n*k)!, {k, 0, Infinity}] {{-(32 E^(-(5/4) - Sqrt[33]/...
1
vote
1answer
87 views

Why am I getting incorrect Eigenvectors for my matrix? [closed]

When i try and compute the Eigensystem using Mathematica i am getting negative values for my Eigenvector, but my Eigenvalues are correct but my Eigenvectors are incorrect and i do know why is that? \...
4
votes
3answers
810 views

How to speed up large double sums in a table?

I am calculating a 3-by-3 matrix whose elements are given as follows: $$ M_{mn} = \frac{1}{N}\sum_{i=1}^N \sum_{j=1}^N (r^i_m - r^j_m)(r^i_n - r^j_n) \tag{1} $$ where $N$ is the total number of ...
0
votes
1answer
46 views

Simplifying an expression involving a matrix and functions of it

I have implemented the following two matrices in Mathematica in order to compute s, but I don't know how I can further simplify the resulting expressions, e.g., ...
1
vote
1answer
29 views

Verify that a PDE is satisfied by a matrix consisting of functions satisfying a different PDE

My problem is as follows: I have two matrices $P$ and $Q$ which are made up of algebraic expressions of a function $q(x,t)$ which solves a somewhat complicated pde, and its derivatives, for example, ...
0
votes
1answer
59 views

How do I create a Jacobian matrix for a large system of equations?

I would like to create a Jacobian matrix using the simplified functions below: f1[a_,b_,c_]:= a^2 + b^2 f2[a_,b_,c_]:= c/2 f3[a_,b_,c_]:= b^3 I say simplified ...
1
vote
2answers
55 views

Matrix whose coefficients are functions

What is the right way to declare of matrix whose coefficients are functions of a variable $x$ ? I tried : Table[Table[a[i,j][x_],{j,1,NN}],{i,1,NN}]
3
votes
2answers
347 views

How to denote matrix elements succinctly? [closed]

Is there a more elegant way of dealing with the following subscripting? ...
1
vote
1answer
36 views

Show result of matrix operation in terms of user defined matrices

I have defined some matrices K[0],K[1],...,K[9] and S[1],...
6
votes
4answers
371 views

Find the identical rows in a matrix [duplicate]

Suppose I have the following matrix: ...
1
vote
1answer
75 views

How to create a dot product version of the product function

I would like to create a function to matrix multiply (dot product) n matrices together, where n is large, for example M1*M2*M3*M4*M5*...*Mn I know there is the 'product' function that can do this ...