Questions on the manipulation of matrices in Mathematica.

learn more… | top users | synonyms (1)

1
vote
3answers
72 views

How to convert a matrix into a sparse matrix [duplicate]

If I have a matrix: row 1)1 0 0 4 row 2)0 0 0 0 row 3)5 1 0 0 row 4)0 5 0 0 row 5)0 0 0 9 How would I put it in a sparse matrix format: ...
7
votes
1answer
87 views

A few tuples at a time?

I want to generate $n$ by $n$ binary arrays, and then reduce the output from those arrays by performing a number of permutations and eliminating duplicates. The problem is that the number of arrays ...
5
votes
2answers
244 views

Speed-up the computation of this sum of small matrices

Given a matrix mat with a large number of rows (a few thousands) and a few columns (between 2 and 10), I'd like to compute the sum of the "small" matrices obtained ...
0
votes
0answers
44 views

Problem with stress transformation using InputField [duplicate]

I want to write a code for application of the transformation matrix onto a second-order stress tensor. I have a problem with showing the results. My steps are as follows: 1) I create a Grid with ...
-3
votes
1answer
46 views

Singular matrices with index 1 [closed]

If $A\in \mathbb{R}^{n\times n}$, the index of $A$ is the smallest integer $k$ such that $rank(A^{k+1})==rank(A^k)$ I want to find a singular (id est $\det(A) == 0$) and non symmetric matrix $A$ ...
1
vote
2answers
53 views

Importing data, then plotting ListPlot. What's the most efficient way to write a code?

It should be a boring question to ask for someone, but this is very basic need which I haven't resolved by myself. I know I can use MapThread and pure function to make it short and beautiful, but even ...
14
votes
6answers
425 views

Given a large binary matrix, find the largest submatrix containing non-zero elements

I'm looking for a way to reduce a binary matrix containing zeros at some positions into a matrix that contains no zeros by deleting rows and columns of the original matrix until only non-zero values ...
1
vote
1answer
41 views
9
votes
4answers
247 views

How to convert a sparse matrix to a list of sparse arrays?

I have a matrix stored as a SparseArray. How can I convert it to a List of its rows, where each row is stored as a ...
1
vote
2answers
73 views

Is it possible to draw a line on a MatrixPlot that would reflect density of row values? [closed]

I have a MatrixPlot with some data and I'd like to draw a vertical lines representing the "average" (density) of that data for each row. Something like this for ...
5
votes
3answers
118 views

Finding most general matrices $A$ and $B$ such that $A\cdot B=1$

I would like to find the most general shape of matrices $A$ and $B$ such that $A\cdot B=1_{4\times4}$. Naively, I just define for example ...
0
votes
1answer
62 views

Varying constant in Matrix calculation to generate 3D plot

As suggested, I rewrite my code to make it simpler and directly showing the problem. Here is a short example. I'd like to generate 3D plot where x,y,z (= a,b,answer) while I am varying a (0 ...
-1
votes
1answer
67 views

Find inverse of the parametric matrix [closed]

I want to calculate the bellow parametric matric but I faced with this error: any suggestion?? ...
4
votes
4answers
284 views

Constructing a large tridiagonal matrix with alternating signs

What is the best way to construct a large tridiagonal matrix, in the following form (notably with alternating signs)? $\mathbf M = \begin{pmatrix} 0 & a & 0 & 0 & 0 & \cdots ...
3
votes
0answers
78 views

Find the generators and group description of a set of matrices [closed]

I have the following matrix elements: ...
2
votes
2answers
124 views

Repeated multiplication of a square matrix and a column vector in Mathematica

I am very new to Mathematica and StackExchange, so pardon me if I am repeating a question that has already been answered. I am trying to use Mathematica to do the following: u[n+1] = A.u[n] where A is ...
11
votes
2answers
388 views

Expressing the n-th power of a matrix [duplicate]

My matrix is $\qquad A= \begin{pmatrix} {1} & {2} & {3}\\ {4} & {1} & {0}\\ {0} & {5} & {4} \end{pmatrix} $ I need $\qquad A^n$ I tried ...
6
votes
6answers
256 views

How do I build a patterned matrix (high-pass and/or low-pass filter bank)?

I would like the shortest code to build the following matrices, of arbitrary dimension $N$: A Low-Pass filter bank matrix is of the form $ \begin{bmatrix} 1 & 1 & 0 & ...
3
votes
0answers
158 views

Mathematica's Singular Value Decomposition different from another math engine [closed]

I’ve been working with SVD – singular value decomposition. Things weren’t working as expected. Thus, I looked over to Matlab and executed the following code: ...
3
votes
2answers
507 views

How do I get the inverse of a homogeneous transformation matrix?

I want to get the inverse of this homogeneous transformation matrix: iab = { {1, 0, 0, 0}, {0, 0, -1, 0}, {0, 1, 0, 3}, {0, 0, 0, 1} } ...
9
votes
1answer
106 views

UnitaryMatrixQ function not returning true for a unitary matrix

So I know this matrix is unitary. It's a well proven fact in quantum mechanics and you can even check for yourself on pen and paper, Heres a quick proof: Assume $H$ is hermitian (i.e. $H^\dagger=H$) ...
1
vote
1answer
44 views

Array Flattening arrays of matrices given by rules

Fix an $n$ and an $m$ positive integers.I have some set of four $n\times n$ matrices $A$,$B$,$Y$,$Z$ (where $Z$ is the zero matrix). I'd like to input the $nm\times nm$ matrix of block matrices given ...
1
vote
2answers
118 views

Update: Calculate Tensor products and traces with Mathematica

My goal is to algebraically simplify expressions involving tensor products and taking the trace. That is, I would like to compute $\operatorname{Tr}\left( \prod_i(id+a_i \otimes b_i) \right)$, using ...
12
votes
7answers
633 views

Brackets around each item in matrix

I have a matrix where every item in the matrix has its own brackets that I do not want. How can I remove the brackets around each item?
1
vote
0answers
29 views

MatrixForm in Mathematica [duplicate]

I wanted to do subtractions between to matrices and I did the following ...
0
votes
1answer
75 views

what do those signs #1, #1^2, #1^3, & mean here? [duplicate]

I have read common pitfalls page and the documentation page but I still don't understand what do those signs mean here? ...
-7
votes
2answers
67 views

How to solve for the eigenvalue in matrix? [closed]

For which value of $a$ in the matrix {{a,2}, {3,4}} has the matrix eigenvalue of $0$? How to solve it in Mathematica?
3
votes
1answer
77 views

Calculating products of given length of two matrices

I have the following problem to solve. Let us have two given square matrices $A$ and $B$ of the same size and a positive integer $n$. I would like to produce all products of length at most $n$ of ...
7
votes
1answer
182 views

Incorrect Left and Right Eigenvectors in Mathematica

I'm trying to find the Left and Right Eigenvectors of a pretty straightforward matrix, but Mathematica doesn't seem to be able to do it for even a 200 dimensional matrix. Background: Given an ...
4
votes
0answers
168 views

Finding eigenvalues in Mathematica: why so slow?

I am trying to find the eigensystem of a large sparse real symmetric matrix, and I only need the lowest 40 or so eigenstates. The relevant code is as follows: ...
0
votes
4answers
122 views

Constructing an arbitrary dimensional matrix with a certain rule

I want to construct the following matrix $M$ of dimension $(N+1)\times(N+1)$ with the following rule (for arbitrary N). Below, in the subscript, as usual, the 1st index gives the row and the second ...
2
votes
1answer
34 views

Encoding/Decoding matrices as integers, integers as matrices [closed]

I want to convert large binary matrices of m x n dimensions into integers, and then to convert these integers to the original matrices. I attempted the following: ...
1
vote
1answer
65 views

Monitoring a matrix with changeable elements as Manipulate in plotting [closed]

If we remember, Mathematica has an ability to show a Psudo-window of plots for monitoring the effects of some changeable parameters in the functions. For example ...
1
vote
1answer
95 views

diagonalization function

If we have a matrix m which is n*n, how can I do mm=U^dagger m U which is a transformation ...
2
votes
2answers
110 views

plotting eigenvalues with devoted level coloring

I am about to plot eigenvalues of a matrix versus varyingj's. ...
6
votes
1answer
62 views

Constructing a particular Toeplitz matrix with a certain rule

I want to construct a Toeplitz matrix in Mathematica. Usually it is done in Mathematica using the following command: ToeplitzMatrix[{a,b,...},{a,y,...}] I want ...
0
votes
2answers
79 views

Flipping random elements in a matrix

I'm still a beginner with mathematica so maybe the solution is obvious, but for some reason my code that worked fine earlier doesn't work now. I haven't changed anything about it. I've restarted ...
0
votes
1answer
35 views

What is the function “oneflag_:0” in this expression? [closed]

The first function Pivotdown can zero out all entries in a column below a desired location. But l don't know the function of “oneflag _0".
1
vote
1answer
54 views

Generate a simulated covariance matrix

I am working on a problem where one of the input variables is the level of covariance between the entries in a particular matrix. To simulate this problem in Mathematica, I will need to feed my code ...
4
votes
1answer
60 views

Computing the logarithmic spectral norm rapidly

I wish to compute the logarithmic spectral norm of a square matrix $A$, which is defined by \begin{equation} \mu_2[A]=\lim_{t\downarrow0}\frac{\|I+tA\|_2-1}{t}. \end{equation} Hence, I simply code ...
5
votes
3answers
239 views

Make a vector of sums of matrix rows

I have a matrix in Mathematica: ...
6
votes
3answers
267 views

How can I create a random symmetric matrix in this way?

The most straight forward way for me to think about is like this: ...
0
votes
1answer
34 views

Picking some elements of a matrix and generating another matrix [duplicate]

If we have a nested matrix as: start={ {{1, 2, 2, 3}, {1, 1, -2, 1}, {3, 2, 2, -I}, {1, 2, 0, -I}}, {{3, 4, 4, 0}, {1, 1, 4, 1}, {3, 3, 4, -1}, {1, 1, 2, I}} } ...
2
votes
1answer
37 views

wrong result of an iteration related to replacement and comparing

We have two nested matrix and a code for replacement following an equality as: ...
1
vote
3answers
120 views

Conditionally binarizing matrices

I want to (fastly) convert matrices with values that are <= a threshold to binary matrices. I used a call to Binarize, but I don't like the Image and ImageData conversions as they obfuscate the ...
4
votes
2answers
94 views

replacement in a nested matrix

We have a nested matrix m1 = {{{1, 2, 2, I}, {1, 1, -2, 1}, {3, 2, 2, -I}}, {{3, 4, 4, I}, {1, 1, 4, 1}, {3, 3, 4, -1}}}; we must replace the first number of ...
6
votes
0answers
129 views

Why has Version 10.3 precision reduced?

In version 7.0.1.0 and versions 10.0 and 10.1 the following is produced: ...
2
votes
1answer
62 views

Why the curly bracket? [closed]

Why are there the curly braces in the output of DY = {{Cos[ay], 0, Sin[ay]}, {0, 1, 0}, {-Sin[ay], 0, Cos[ay], 0}}; DY // MatrixForm It looks inconsistent ...
3
votes
1answer
143 views

Hasse Diagrams from Adjacency Matrix

Let's say I have a rather large adjacency matrix for a partial order relation. Say an 80x80 matrix. What is the best way to display Hasse diagram? I have tried AdjacencyGraph and it does a not so bad ...
1
vote
1answer
45 views

How to find selected elements of inverse of a banded matrix without inverting it?

Is it possible to find some selected elements of the inverse of a large sparse matrix without inverting it? For example consider this Hermitian matrix (as a general case). ...