# Tagged Questions

Questions on the manipulation of matrices in Mathematica.

2answers
53 views

### Plotting points using adjacency matrix

Given an adjacency matrix on n vertices and a polygon on n vertices, how to add edges from adjacency matrix on the Polygon? eg: if polygon is {(0,0),(0,1),(1,0),(1,1)} and the adjacency matrix has 1 ...
2answers
463 views

### Convert DelaunayTriangulation-> Graph->AdjacencyMatrix

Is there a way to convert a Delaunay Triangulation into a Graph structure so that one can generate an AdjacenyMatrix of the Delaunay?
1answer
52 views

### Finding an Integer, Unimodular Matrix that connects two given matrices

I have two symmetric, integer matrices, $K$ and $K_2$ which have the same determinant and the same signature (number of positive - number of negative eigenvalues). I want to find an integer valued ...
0answers
56 views

### Map over multidimensional matrix [closed]

Suppose I have a 8by6by4by2by2 matrix called m. There is in total 8*6*4 2by2 matrices. I want to map a function over these 2by2 matrices. Each dimension in ...
1answer
66 views

### What's up with PauliMatrix with a string argument?

Looking at the definition of PauliMatrix (not the documentation), I realized that it is defined for arguments 0, ...
1answer
93 views

### Is it possible to decouple this Matrix A to matrix multiplication of two matrixs B and C?

I want to decouple this matrix A into two matrixs B and C, with A=B*C. And B is functions of r, C is functions of n. Is it possible or not? Can I use Mathematica to do this? Any help or advise is ...
1answer
78 views

### Help on order of evaluation within plot function

it is my first time asking a question here so please let me know if there's anything I should be doing that I'm unaware of. I'm sure the answer to my question already exists on the site but I'm having ...
1answer
92 views

### Accessing the elements in a table is slower than calculating each time?

This is a follow-up of How to accelerate combinations and sum calculations here? I have tried all tricks but when N reaches 35 the time is still intimidating in a 16-core server, which is far better ...
1answer
155 views

### Defining a matrix with elements acting as operators

This question is directly related with my previous one. I'll try to be more specific here. I have a matrix {{a[x],b},{c,d}}, where ...
2answers
274 views

### Find a condition that b must satisfy so that Ax=b has solution

I'm new to Mathematica, so I'm sorry if this is really simple. I am trying to find the condition that vector b must satisfy so that Ax=b has solution. I would like to learn a general method, but I'll ...
0answers
40 views

### How to plot eigenvalues as a function of parameters in a dynamic module?

I am trying to make a fancy interactive plot that shows how the eigenvalues of a matrix mat change under variation of parameters ...
2answers
98 views

### Dynamically sized $n\times n$ checkboxes corresponding to a matrix

I was wondering if it was possible to do to following: have an input field for an integer where you input the $n$ have an $n\times n$ matrix of checkboxes that would correspond to an $n\times n$ ...
7answers
336 views

### How to repeat a matrix on it's side?

I have the following matrix in Mathematica: mat = {{0,0,1,1}, {0,1,0,1}} I want to repeat this matrix N number of times on the side. For example if N = 3 then ...
1answer
68 views

### Eigensystem with orthogonal elements in matrix

I have a matrix with 16 elements: matrix = {{f1, -f2, -f2, f3 }, {f4, -f1, -f1, f2}, {f4, -f1, -f1, f2}, {f5, -f4, -f4, f1}} I would like to calculate ...
4answers
121 views

### mapping a smaller matrix in a greater matrix with a specific sequence

I have a matrix 300x300 i need to map the values ina greater matrix (900x900) in the positions given by the sequence $$({3*i-1,3*j-1)}$$ while everything else remain empty, how can achieve this ...
3answers
92 views

### How to Import and Export as a multidimensional array

I have 10000 matrices and each matrix is 3x3. So Dimensions[data] gives me {10000,3,3}. I saved this into a file with Export["mydata.dat",data,"Table"] Then when I imported it using Import["mydata.dat"...
3answers
389 views

### Can't find the eigenvectors of a simple 2x2 matrix

Bug introduced in 8.0 or earlier and fixed in 10.3.0 Why can't Mathematica find the eigenvectors of this matrix? ...
1answer
64 views

### How to accelerate combinations and sum calculations here?

I have a 4d matrix H defined as below (embedded with combinations and sums) ...
1answer
60 views

### Fast Eigensystem calculation

I have a code which finds the eigensystem for a matrix H = H0 + x HInt, where x is a variable which turns on the interaction. H0 is diagonal, and HInt is a sparse matrix (with about 400 states, I hope ...
2answers
249 views

### Dynamical system problem x(t+1) = Ax(t)

I have a problem that have been trying to solve but it's not going so good. I would like some guidelines on how to work myself around this problem: Two neighboring countries spy on each other and ...
0answers
38 views

### Matrix with equations as entries - how to choose them and solve them

I have a matrix in Mathematica, which I have built using Normal[SparseArray]. Each entry of this matrix is an equation in one variable. What I need to do is 1) to select some of the entries of the ...
2answers
133 views

### Replacing multiplication of matrix elements by application of these elements as functions

I want to realize the following idea in Mathematica. I've got a matrix {{a,b},{c,d}} which is multiplied to a vector {h,k} ...
2answers
82 views

### Building an $m \times n$ matrix from element-wise from two other such matches

I am a beginner with Mathematica. I have two matrices, s1 and s2, and I am building a third matrix from them. ...
3answers
403 views

### Noise filtering in images with PCA

I have a stack of images (usually ca 100) of the same sample. The images have intrinsic variation of the sample, which is my signal, and a lot of statistical noise. I did a principal components ...
0answers
94 views

### How does Mathematica compute the determinant of a matrix? [closed]

I have been trying to write efficient code for calculating the matrix determinant for some time now. I noticed last night that Mathematica is able to compute the determinant of a $200 \times 200$ ...
1answer
161 views

### Drawing dynamical trajectories diagram in Mathematica

I've a Boolean gene regulation system composed of vectors(corresponding to cellular phenotypes). Their components are binary numbers such as $\{1,0,0,1\}$. A vector can change its statement in ...
1answer
70 views

### Save a fraction matrix in Mathematica into C++ friendly format

In MMA I have a 2d matrix whose each entry is a irrational number(in fraction format in MMA). Say: ...
3answers
6k views

### Solving a time-dependent Schrödinger equation

I want to solve the time-dependent Schrödinger equation: $$i\partial_t \psi(t) = H(t)\psi(t)$$ for matrix, time-dependent $H(t)$ and vector $\psi$. What is an efficient way of doing this so that ...
1answer
59 views

### Unexpected result: Numerical and analytical results do not match! [closed]

I am calculating the eigenvalues and eigenvectors of a matrix. This is my code: ...
3answers
269 views

### Get the coefficient matrix from a quadratic form

Suppose I have a quadratic form of qf = a x^2 + b y^2 + c z^2 + 2 d x y + 2 e x z + 2 f y z How can I easily to get the symmetric matrix A, such that $X^TAX=qf$?...
1answer
157 views

### Why FoldList 5 times faster than Apply for matrix multiplication? [duplicate]

Consider this list of $2\times 2$ matrices: list=RandomReal[{-2,2},{500,2,2}]; Now compare timings of Apply and ...
1answer
128 views

### Optimize a parametric matrix to get a lowest possible eigenvalue

This question is a followup of Plot the lowest eigenvalues of a parametric matrix Now I can get the lowest eigenvalue LowEign(t) of the matrix for a given t numerically. When I plot the LowEign ...
2answers
73 views

### Automatic process to replace missing values, coming from a second matrix

I have a large starting matrix with missing values in different columns. I want to replace this missing data as follow. First I have to check the group (last column in starting matrix) and go to a ...
1answer
66 views

### Plot the lowest eigenvalues of a parametric matrix

The question here is somewhat related to the comments in Computing eigenvectors and eigenvalues I have a matrix M, say 400 by 400, and all elements depend explicitly on one parameter t in a ...
2answers
6k views

### How to form a block-diagonal Matrix from a list of matrices?

For example, like this: I know join[...] works, but it is a bit troublesome for multiple matrices. I also tried DiagonalMatrix[...], but DiagonalMatrix can only form a matrix from a list of ...
3answers
93 views

### How do I create a circulant matrix? [closed]

How do I create an $n \times n$ circulant matrix? I couldn't make ToeplitzMatrix do it for me.
1answer
25 views

### Passive Transformation does not return the expectedt result due to precision of expressions

So I wish to perform a passive rotation in N dimensional space. Let me take N=5 for this question. ...
1answer
111 views

### Evaluate pure function through round brackets

In have some matrices of pure functions or numbers which I multiply by other matrices or vectors. I would like the functions to be evaluated in the result, but all that I get is something like this: <...
1answer
77 views

### Create a Dataset object, Association or SparesArray from a matrix [closed]

I need to make queries and operations on a large dataset. What is the easiest way to add keys to matrix so that it is transformed to a dataset, which can later be used to make queries? Let's take ...
2answers
122 views

### Delete rows and columns in a matrix based on the element index

This is a follow-up question from here: Define a 4d matrix without for loop I have a 400x400 2d matrix reshaped from a 4d matrix H(i,j,k,l), ...
2answers
90 views

### Define a 4d matrix without for loop

I was wondering if there is a way to avoid for loop here: I want to define a 4d matrix H(i,j,k,l), and each entry in the matrix is calculated through a complex function, say Do_H(i,j,k,l), depending ...
2answers
106 views

### Find the minimum element of a row of a matrix and its column index for each row

I am trying to find the minimum value of a row of a matrix and its corresponding column. Please run the code below. OptV is the matrix that I would like to create which must give the output of the ...
2answers
142 views

### Good way to create a similarity / distance matrix for a large dataset [duplicate]

I have a large dataset with rows (100k+) for products and columns for features. Now I want to create a similarity matrix with NormalizedSquaredEuclideanDistance. ...
0answers
49 views

### Value Iteration (Recursive iteration) to Minimize (Optimize) a Function

I have a function that I call as "Value". I am trying to find the minimum of this function and this function is a function of 4 other functions. One of these four functions is recursive based on the ...
1answer
155 views

### How do you solve a linear equation of matrices? [duplicate]

The function Solve works fine for scalars: In[]:= Solve[A x - x B + C == 0, x] Out[]= {{x -> -(C/(A - B))}} When using matrices however, ...
1answer
40 views

### Square bracketed matrices in Mathematica - precision markers?

I'm trying to display Matrices with square brackets in Mathematica. I've found this post from a mailing list in 2009 http://forums.wolfram.com/mathgroup/archive/2009/Aug/msg00458.html and it seems to ...
1answer
137 views

### Calculate the ESP Grid based on Density Grid

I want to build a fast way to convert a density grid file into a grid file of the respective electrostatic potential (ESP; also known as MEP, the molecular electrostatic potential). This ...
4answers
454 views

### How to simplify block of multiple repetitive If statements?

I'm building a boardgame...game in Mathematica. I have the board state represented as a matrix. It's a two player game, and each player (let's call them A & B) only has one type of piece or '...
2answers
91 views

### I'm trying to solve a system of complex equations

I'm simply trying to solve a system of equations and mathematica can't do it for all values over the region of interest. I have a 3x3 matrix that has a specific parametrization and after squaring the ...
2answers
95 views

### Plot values of an $m\times n$ matrix on the complex plane with color varying along $m$

Let's say I have a complex valued matrix $\begin{pmatrix}1+I&2+2I&3+3I\\4+4I&5+5I&6+6I\end{pmatrix}$ represented by a list: ...