Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions on the manipulation of matrices in Mathematica.

1
vote
2answers
18 views

Subtracting off background data from my data sets

I don't know how to subtract off background data Data0 from my data sets collected in Datagen. ...
1
vote
1answer
116 views

Forming Kronecker products for “non-adjacent” vector spaces

In quantum mechanics, we often want to build operators acting on multiple particles by simply "Kronecker-ing" operators from the single-particle spaces. That is, if I have some matrix $A$ acting on ...
5
votes
4answers
154 views

Constructing higher order transition probability matrix

Recently I asked a question here about how to construct a transition probability matrix given the following list: ...
3
votes
3answers
128 views

How eliminate { } in an arbitrary order in subgroup of a nested matrix

How can reach the second matrix from the first nested one: ...
1
vote
1answer
47 views

Generate “nice” random matrix

I don't frequent this community so please give criticism if this is a poor question. I am trying to make a tool which generates a small (say, 4x4) matrix with integer entries which has a "nice" ...
3
votes
1answer
43 views

Basis for unstable manifold of a matrix

Given a square matrix A, how can I generate a basis for the generalized eigenspace corresponding to all eigenvectors $\lambda_i$ such that $\vert \lambda_i \vert &...
4
votes
3answers
167 views
2
votes
1answer
32 views

Calculation of a matrix determinant for general matrix size

Problem: I have a matrix of the following form Table[Which[i == j, -2 Cos[k], i == j + 1 , 1, j == i + 1, 1 , True, 0], {i, 1, m}, {j, 1, m}] and I want to have ...
0
votes
0answers
28 views

matrix perturbation general formula with random values

Is there a way to generate an arbitrary-sized diagonal matrix of variables, not numbers, in mathematica? Probably unnecessary context: For a research question I'm pursuing, I want to find general ...
0
votes
0answers
44 views

evaluation of a probability

Hy my program i running only for one value but i want to run this for several values By addind result of previous one at a same time.... my program is ...
0
votes
1answer
40 views

Table Creation Slow Performance

The following is a question in regards to the matrix $A$ (originally the zero $4n \times 4n$ matrix) below: ...
0
votes
0answers
48 views

Assign a variable to an expression in Mathematica

I have the following matrix {{a^2 + b + \[Sqrt](m + n) + 5, 23 x + 7 a}, {14 b, a^2 + b + \[Sqrt](m - n) + 5}} I want to replace the expressions ...
1
vote
0answers
42 views

General block diagonal matrix [duplicate]

I am constructing a matrix using the following code ...
5
votes
2answers
254 views

Replace values in sparse matrix

I am interested in updating the values of the sparse matrix. I have a list of matrix element which I am interested in updating and a list of new values. Currently, I do it in the following manner: <...
4
votes
2answers
230 views

Handling arrays

Is there a way to transform a matrix in a vector, where you choose the order of the arrangement? I used ArrayReshape but this command chooses its own arrangement, ...
0
votes
0answers
34 views

Matrix with 5 diagonal

I'm solving 2D time dependent Schrodinger equation. At some point a have to solve a linear system like this $$A\chi=B$$ where the matrix A has five diagonals and everything else is zero. I've alredy ...
2
votes
1answer
58 views

How to speed up `ReplaceRepeated` `//.`?

I have to replace all the elements smaller than 0 in a large matrix to 0.But i found the speed is really slow when the matrix is big. Here is my code. ...
4
votes
2answers
108 views

Get the number of specified elements from the SparseArray properties

In the sparse matrix, we have a list of properties: specified elements, dimension, default, and density. I am interested in getting this data without calculating them again. For an example, the ...
3
votes
1answer
60 views

Get the dimensions from the SparseArray properties

In the sparse matrix, we have a list of properties: specified elements, dimension, default, and density. I am interested in getting this data without calculating them again. For an example, the ...
1
vote
1answer
46 views

Implementation of discrete Fourier Transform in Matrix Form

I am trying to gain an in depth understanding of how discrete fourier transforms work, and consequently I am trying to implement the discrete fourier transform myself in the form of a matrix. First ...
0
votes
2answers
54 views

How precisely does Mathematica handle/record an isolated error in one of a long series of separate calculations?

I'm generating a series of (numerical) matrices, and testing each one for a certain property, and trying to estimate what proportion possesses that property. I write out the result at every million-th ...
3
votes
2answers
81 views

Unable to evaluate Eigenvalues and Eigenvectors for a matrix

I have the following 3X3 matrix M and I wish to find its eigenvectors and eigenvalues ...
1
vote
1answer
29 views

Diagonal Matrix of a Piecewise Function

I have a piecewise function now I want to do a Matrix operation on it. How can I do that? For example, the Function is like below: ...
0
votes
4answers
85 views

Matrix using For Loop

I am trying to create matrix, where every element is generated from For Loop. Just for simplicity,let's consider the following mathematical problem: Find maximum value of the function $x^2+y^2$ over ...
2
votes
1answer
80 views

Substituting variables inside a matrix

I'm trying to substitute some dependent variables into equations inside of a matrix, however $Replace[]$ and and $/.$ don't seem to work. The equation in question is just a vector matrix of ...
0
votes
0answers
39 views

DAE Jacobian matrix StiffnessSwitching alternative

I am trying to do the Jacobian Matrix of my DAE system. Below you can find a simplified example: ...
1
vote
1answer
43 views

How i can extract different sub matrix using index of sub matrix

Sir i am try to to make a general program that extract different sub matrix that have elements at different positions., here is may program that is well working .. but now i want to transform this ...
0
votes
0answers
39 views

Help! SystemException[“MemoryAllocationFailure”]

I am trying to run this code: ...
2
votes
1answer
41 views

How can I plot different columns of a matrix in a single graph?

j=0; ListLinePlot[Table[u[i][j] , {i, 0, Xmax}], PlotRange -> All] here u is 2 D array and I want to plot all the columns of this 2D matrix in a single ...
4
votes
1answer
102 views

Help with PseudoInverse

I am trying to (pseudo)solve a linear system $Ax=y$. I have a matrix A, and 2 vectors x and y...
2
votes
1answer
55 views

Memory usage for large matrices

I have a quick and probably naive question about how MMA (11.2) handles memory (I am very novice with numerical calculation using MMA..). I have to work with large matrices (of sizes over $30000^2$)....
0
votes
1answer
28 views

Padding a Matrix [closed]

I have the following matrix test={{x1,y1},{x2,y2,z2},{x3,y3},{x4,y4,z4,u4}}, I am looking for a rule that 1) finds the max length of a row (=4 in this example) and ...
6
votes
1answer
287 views

How to find k largest element and their position in a matrix?

I have a sparse matrix, and I am interested in find k largest elements and their positions in the matrix. I do it in the following manner: ...
5
votes
1answer
70 views

How to use ComponentMeasurements with a matrix?

The function MorphologicalComponents works on both images and matrices, as in the following code: ...
1
vote
1answer
46 views

Adding a zero vector into an inside column or row of a matrix [duplicate]

Let's say I have a 3x3 matrix and I want to insert zero vector into all second row and all second column of the matrix. At the end, the previous second row shifted to third row and the previous second ...
1
vote
1answer
59 views

Plot nested matrix and label according to sublist

I have a nested matrix xyPairsAll that contains {x, y} pairs: ...
2
votes
2answers
54 views

How to split sublists into sub-sublists without merging the sublists

This is an extension of this question. I have xyPairsAll, which is a matrix holding sublists. It looks like ...
3
votes
1answer
109 views

Cosine similarity calculation

I am interested in calculating the cosine distance between each pair of the element of a sparse matrix. I am using the built-in function DistanceMatrix with the ...
2
votes
1answer
94 views

Plotting eigenvalues in one plot for three different parameters

I am trying to plot eigenvalues of the matrix with different $W$. I can plot them separately but I want to merge them in a single plot with different colors. Is there any other type of plot other than ...
2
votes
1answer
36 views

Create sublists of x, y pairs for multiple y-coordinates

I have a matrix data in which column 5 holds x-coordinates, and then columns 6 through 37 each holds sets of y-coordinates. I want to map x, y pairs, keeping the ...
2
votes
2answers
73 views

Creating 15x15 matrix out of two 6x6 matrices (by antisymmetrization)

I would like to create the following $15\times 15$ matrix $A_{ij} = \Lambda^{[I}_{[J} \delta^{M]}_{N]}$ It is tricky because $A$ is a $15\times 15$ whose entries $ij$ are labeled by antisymmetric ...
1
vote
1answer
48 views

Recognizing Summation Indices in Mathematica

Consider some complicated expression like the following: $$ Q[a,b]Q[a,c]M[a,c]M[a,b]$$ Where the lower case letters are matrix indices. I am looking for a way to make mathematica recognize all the ...
1
vote
1answer
31 views

Evaluate a function with vectors and return matrix

I have a matrix given as a function of is indices and another free parameter as follows A[x_, i_, j_] = x*i*j Now I would like to evaluate this for a given ...
7
votes
1answer
112 views

Speed up the generation of large Hadamard matrices

I need to generate a Hadamard matrix with dimensions of 4096 but it seems Mathematica is much slower than Matlab when generating such matrices. This program ...
2
votes
1answer
41 views

Getting error message from NSolve

I'm trying to solve for coefficients $k1$, $k2$, $k3$, $k4$ in the following equation: $\det\left(\,\begin{bmatrix}k1+k2 & -k2 & 0\\-k2 & k2+k3 & -k3 \\ 0 & -k3 & k3+k4\end{...
5
votes
3answers
996 views

Incresing efficiency of the code:

I have a set of points, representing location of events in a map, and I want to find the closest neighbour for each point. Variable xys is a 2D matrix containing ...
0
votes
0answers
37 views

How to check if two subspaces are conjugate?

I want to check if there exists an element $g \in SL(2,\mathbb{R})^2$ such that $Ad(g) \mathfrak{h} = \mathfrak{h}_\lambda$ for some given subalgebras $\mathfrak{h},\mathfrak{h}_\lambda \subset \...
3
votes
1answer
140 views

Finding optimal rotation matrix

I have vectors E1 = {22.607, 3.495, -30.795}; and R1 = { 4.74061, 21.7549, 30.6501};. This vectors are conneted by a 3D rotation ...
4
votes
2answers
99 views

Simplify the use of Table together with FoldList

I am trying to recreate the following table,where you have the question mark. to do it occupy the following commands, but I would like to help me improve my code to make it more practical especially ...