# Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

3,488 questions
Filter by
Sorted by
Tagged with
1 vote
90 views

### How to optimally defragment the colors? [closed]

This is a matrix plot with randomly selected colors. I like to defragment the colors to create an optimal grouping of cells with the same color. ...
100 views

### Finding a basis of positive vectors in the kernel of a matrix

The kernel to the left of the matrix ...
151 views

### How to plot the elements of a matrix in {x,y,z} coordinates?

I have the {x,y,z} positions of a fullerene and after connecting the first neighbors with ~1.37 and 1.45 distances in the matrix B as the following ...
78 views

### The multiplication result is not written as a number [closed]

This is my code: ...
1 vote
98 views

### How to construct a custom-made matrix conditional on a set of rules?

The following code does what I intend to achieve; however, it is too cluttered for a simple matrix operation. I like to reduce the code to a one-line code as a ...
40 views

### Matrix Dimension Changes [closed]

I am trying to run the following code: ...
42 views

### 'The objective function is not a scalar' in NMinimize

I am trying to do a GMM(Generalized Method of Moments) by NMinimize, it comes up with the warning 'The objective function is not a scalar', here's what I have tried:...
2k views

Toy data ...
78 views

### Convert a string with $N^2$ entries to a rank-$N$ matrix

Suppose we are given a set of numeral data like a string that consists of $N^2$ entries, say $N$ is very large (here $N=8$ for simplicity, but $N$ can be $10^8$...) ...
78 views

65 views

### Giving MatrixPlot coordinates [closed]

I am using MatrixPlot for plotting the following array ...
505 views

### Fill an empty matrix with the depth of its elements

Given an arbitrarily nested empty matrix like for example mat = { {}, {{}, {}}, {{}, {{}}, {}}, {{}, {{}}, {}, {{{}}}} }; and knowing that ...
66 views

### Performance of multiplying two identity matrices

I am running Mathematica 13.3.1.0 on a M1 Mac, and I ran the following codes to check on the time spent on matrix multiplication. ...
365 views

### Eigenvectors are divided by zero depending on evaluation, 6x6 matrix

I calculated the Eigenvectors of the $6\times 6$ matrix $m$ with parameters $(a,b,c,d,e,f)\in \mathbb{R_{\ge 0}}$. If I set e.g. $b\rightarrow 0$ after calculation, then 4 of the 6 Eigenvectors are ...
434 views

### Eigenvectors are divided by zero depending on evaluation, 4x4 matrix

I calculated the Eigenvectors of the $4\times 4$ matrix $m$ with parameters $(a,b,c,d)\in \mathbb{R_{\ge 0}}$. If I set e.g. $b\rightarrow 0$ after calculation, then some of the Eigenvectors are ...
1 vote
109 views

### How to plot a matrix with this 3D style in a bar chart?

Reading the paper Measuring Wigner functions of quantum states of light in the undergraduate laboratory in arXiv, I found the figure above, whose style is very beautiful. I tried to reproduce it, but ...
89 views

1 vote
192 views

### How to implement tridiagonal matrix algorithm?

I have created the tridiagonal matrix below: ...
59 views

### Plotting list of points to a special graph

Given Mathematica code of eigenvalues in different variable-paths , I want to add experimental data in the path Gamma-X ; X-Gamma ; and M-Gamma . Here is the code : ...
29 views

### How to extract subscripts in mathematica and apply a function on them?

For a bit of context, I am trying to evaluate an integration over Haar randm unitaries. I couldn't find any inbuilt function, so I am trying to implement a simple code for the Wingarten functtion in ...
81 views

### Eigenvalue Problem - Nullspace Basis

I need to solve an eigenvalue problem where some of the eigenvalues are 0. Due to the fact that I just need the eigenvectors associated to the 0-eigenvalues in some cases I'd just like to calculate ...
650 views

### Find a certain path through a matrix

I would like to get a functional solution and nice display form for the following problem: 1. Example data ...
1 vote
83 views

### How to calculate maximum between two or more lists element by element and also the index corresponding to the maximum element?

I am looking for a function say f such that for example f[{a1,b1,c1},{a2,b2,c2}] will give {Max[a1,a2],Max[b1,b2],Max[c1,c2]} and also a function g say such that g[{{a1, a2, a3}, {b1, b2, b3}},{{c1, ...
66 views

### Efficient ways to generate a matrix from multiplying two elements of some matrix

I am working on the single particle entanglement entropy and in the process I have something like ...
91 views

### Solve does not find solutions to large equation rotation matrix

I've been seeing some posts already where people mention Solve needs a bit of help to get things solved in some scenarios. I have been trying to figure out the solutions for equations. For the XYZ ...
1 vote
123 views

### Using "Table[]" to create a matrix without submatrices [duplicate]

I'm trying to create a certain 6x6 matrix using Mathematica's in-built "Table[]" function and have landed on ...
112 views

### Interpolation of missing matrix values

Problem statement I want to replace missing matrix values, denoted by an integer 0, with the Mean of their surrounding values. ...
785 views

### How can I expand a matrix and fill in zeros?

Given a square matrix like m = {{1,2,3},{4,5,6},{7,8,9}}; I want to expand it to a 5x5 matrix ...
67 views

### Elegant operations on associations and datasets

As a useful extension of this question: Elegant operations on matrix rows and columns I would like to ask: What are for you elegant, short, useful or frequently used functions to use with ...
113 views

### Simple subtraction of two square matrices giving strange results [closed]

I'm new to Mathematica, and I'm writing a function to calculate a complicated pdf. I'm having trouble doing something very basic, subtracting one square matrix from another. I've reduced my problem to ...
43 views

### On MacOs, I cannot use Needs["QDENSITYQdensity"]

I am trying to get Needs["QDENSITYQdensity"] from (https://library.wolfram.com/infocenter/MathSource/5715/), however, it failed and I get this error: ...
85 views