# Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

2,275 questions
Filter by
Sorted by
Tagged with
1answer
94 views

### Writing equation of motion in matrix form

How can I write the equation of motion of a system of N variables: x1, x2, ..., xN, (these are all functions of time) in matrix form? For example, ...
0answers
41 views

### How to save a multidimensional matrix in separated files for each dimension

I need to export to a file a multidimensional matrix, each dimension to a file. For example: ...
1answer
88 views

### How to write the equation into matrix form [closed]

$[(a+k_i)^2+(b+k_j)^2]X_{i,j}-\sum_{m,n}V_{m,n}X_{i-m,j-n}=\mu X_{i,j}$. where $-N\le i,j\le N$ Here we can set $N=10,a =1, b=1$ and $V_{m,n}$ is the matrix element of $V$. Once I write the ...
1answer
100 views

### How to visualize the matrix transformation?

Actually, the question is related to this topic, but it is no expected answer there. And it seems the following answer leads to another direction. As we know, we can visualize the vector by ...
1answer
80 views

### Using Condition (/;) for constructing big matrices [closed]

I want to construct a big matrix where the input of the matrix element is based on the relation between the row indices and column indices. Here's an example of what I tried but did not work: ...
2answers
100 views

### Element-wise multiplication of matrices with different dimension

I am interested in efficient element-wise multiplication of matrices with different dimension. Here is my solution: Matrix 1 with dim = {3, 4, 4} ...
4answers
175 views

### Changing the position of rows and columns in a matrix

I have the following self-explanatory question. https://1drv.ms/u/s!AsyHs3E_aioxhipb3wSPSX_heN-t As seen from the above matrices, I start with the "original" ...
2answers
282 views

### The multiplication of list of matrices

I need to multiply 3 lists of matrices (b.a.b) as the following code ...
0answers
78 views

### Orthogonal matrix decomposition of symmetric matrix?

If matrix mat is symmetric, we should be able to decompose it into eigenvalue matrix matJ and orthogonal matrix ...
5answers
482 views

### How to generate binary array whose elements with values 1 are randomly drawn

I am trying to generate a binary matrix (whose elements are 0 or 1) of dimension 20x20. To do this, I want to supply as input the number of matrix elements that will take value 1. After, I want to ...
4answers
192 views

### Dot product result has wrong dimension [closed]

I'm doing a small project and I've encountered a problem while using Mathematica. I should mention that I'm kinda new to this software, so maybe it's just something I haven't grasped yet. Anyway, I ...
2answers
96 views

### Unable to evaluate Eigenvalues and Eigenvectors for a matrix (2)

I have posted a similar question last year pertaining to this issue. Here's a link to my post together with the solution given: Unable to evaluate Eigenvalues and Eigenvectors for a matrix I have ...
1answer
40 views

### Why do I keep getting the same time from the Timing function?

I am running a gamblers problem solution where I am testing the timing involved in solving the Ax = b equation for matrices of n=100, 1000, 10000, and 100000. For some reason I keep getting the same ...
1answer
37 views

### How can I create a large matrix without running into hangs or recursion errors?

I'm trying to create a probability matrix, starting by creating a 100,000 by 100,000 identity matrix. However, when I try to create this using: ...
1answer
37 views

### constructing Matrix from coefficients of solution & assigning 0 for empty Cells [closed]

i tried to construct a matrix from the coefficients of my solution, but problem that; 1; how can i get coefficients out of Solve 2; some Matrix elements are empty so i must assign 0 in those empty ...
0answers
42 views

### Matrix of deviate scores

I am trying to replicate some steps in Jonathon D. Brown's text "Linear Models in Matrix Form: A Hands-On Approach for the Behavioral Sciences" Brown, 2014, p.12. I am creating a "matrix of deviate ...
1answer
50 views

### Reduce returns false on equation solvable by LInearSolve [closed]

I was looking for general solutions of an equation I already solved for specific values with LinearSolve, but using Reduce returned False. Here's the code: ...
1answer
70 views

### How can I tell if a matrix is ill-conditioned or Singular by using the Eigensystem function(or LUDecomposition)?

I'm using the Eigensystem function, and I'm trying figure out whether or not it is singular or ill-conditioned. I'm using the function as so: ...
0answers
40 views

### SymFullRankQ - a function that calculates the conditions for a matrix to be full rank

I found in this article references to a function that manages to do this: is used to find the conditions for the symbolic matrix E to have full rank This is actually very interesting and useful. ...
0answers
34 views

### Efficient method to find consecutive products in table

Suppose I have a table of matrices, $[A,B,C,D,...,Z]$ and a vector $v$. I would like to efficiently compute both $ABCD...Zv$ and the table $[A,AB,ABC,ABCD,...,ABCD....Z]$. I know that to compute the ...
1answer
77 views

### Graphic representation of a triangle using ArrayPlot

So I need to write a function which takes natural integer $n$ and returns graphical representation of a matrix $n \times n$ using ArrayPlot[]. This matrix has to be ...
1answer
62 views

### A transfer-matrix approach for multi-barriers [closed]

I'm trying to reproduce the results from https://doi.org/10.1063/1.168430. The work study one-dimensional quantum system using a transfer-matrix formalism for multi-barriers with finite-step ...
2answers
60 views

### Table Command with multiple Variables

I am new to Mathematica, so I'm not sure about the ins and outs of what's possible and what is not. I am trying to view the eigenvalues of multiple matrices at once. In particular, this matrix: \...
1answer
73 views

### The best way to export a set of n matrices [closed]

Suppose I have 20 Matrices: Mat, Mat,...,Mat. What is the best way to export (and Import) this set of Matrices in a file? How can I do that? (may be any format, for example: csv). Thanks.
1answer
116 views

### Using Non-Negative Matrix Factorization (NNMF)

I am trying to understand NNMF (Non-Negative Matrix Factorization). This is not a built-in function in Mathematica, but there is a package that implements it, which is refered to in this post. The ...
2answers
98 views

### reducing matrix size by linear operations on rows and columns

Suppose that I have the following matrix: matrix = Table[i+j, {i, 5}, {j, 0, 4}]; which generates I like to write a ...
0answers
63 views

### Calculating forces on a truss

I need to find certain forces of the truss shown above, and I am asked to calculate the forces with a matrix. The given values are ...
3answers
231 views

### Obtaining a matrix of complex values from associations giving the real and imaginary parts of each element?

I have a list of associations keyed by real and imaginary numbers, like so: ...
4answers
153 views

### How to generate a matrix with certain conditions

I want to generate a $n \times n$ matrix. I want the diagonal entries to be all 0 I want a random choice of matrix elements with 0 or 1. The probability of having a 1 as a matrix element is $1/m$ and ...
2answers
130 views

### Constructing a special square matrix

I am trying to define an $n \times n$ matrix for even $n$ using ...
1answer
58 views

### Strange answer for Eigenvalues of a 4x4 matrix [duplicate]

I am getting these strange eigenvalues of this simple looking 4-dimensional matrix: ...
0answers
47 views

### How to optimize the code [duplicate]

How can I write the following code using lesser number of characters? Table[Table[{y - x, y}, {y, 8}], {x, 8}] I tried using ...
1answer
74 views

### Define special matrix in Mathematica [duplicate]

Is it possible to define this matrix in mathematica when N is Odd and N is Even? Thanks
2answers
160 views

### Time-efficient matrix elements grouping and summing

I'm interested in finding the quickest way of grouping the elements of a large matrix in sub-groups of NxM elements and them summing them together. To be completely clear, I'm actually not interested ...
1answer
64 views

### Finding Steady States that Meet Additional Constraints

I've written a function that returns the steady state given a regular, column-stochastic matrix. I want to use it to solve a larger problem, finding steady states that satisfy certain conditions. The ...
1answer
45 views

### Approximate results

I am trying to show that two matrices are the same. One matrix has random elements drawn from a distribution of ${(-0.75,-0.25,0,0.25,0.75,0.95)}$, while the other has values with imaginary parts ...
2answers
47 views

### Simplifying Algebraic Expression With Substitution

Is there a way I can make an algebraic substitution in a matrix? I tried using Simplify[P_rhs _ 51, (c44hat*rhohat)^.5 == zeta] Where P_rhs_51 is a 4x4 matrix. ...
2answers
205 views

### Matrix square root and commutation [closed]

Does a square of a matrix commute with the matrix itself? I have the following code showing that it does not. Is everything fine here? ...
0answers
116 views

### Why can't Nsolve find the solutions for my equations?

I have a problem using NSolve in my Mathematica code. In my Code NSolve should find a value for qw, but it won't. The strange ...
1answer
73 views

### Creating matrices using a Do-loop

Here is an image of current assignment; I am not able to do step 6 to 8 When I try to do the Do-loop, it states that the {i, j} does not have appropriate bounds. ...
1answer
213 views

### Setting Some Elements in a Matrix to zero

Assuming I have the a 5x7 matrix below: b = ((1, 4, 9, 16, 25, 4, 2), (36, 49, 64, 81, 100, 5, 1), (121, 144, 169, 196, 225, 8, 9), (256, 289, 324, 361, 400, 9, 5), (441, 484, 529, 576, 625, ...
2answers
80 views

### Elements Replacement

Please I need help on how to replace elements in a matrix with another elements. For example, I have a (5,5) matrix, and I like to replace elements from All rows and column 3 to 5, with zero. such ...
3answers
263 views

### Converting a list of colors into an image

I want to manipulate colors, and merge the resulting vector and rasterize it into an image, controlling the resolution of the pixel. E.g. I tried to: But what I would like to have is an image of 3 ...
1answer
40 views

### A fast way to create a list with $A_i\cdot B_i^{-1}\cdot C_i$ in each component

Let us suppose I have to do the following computation $A_i\cdot B_i^{-1}\cdot C_i$, where $A_i,B_i,C_i$ are conformable matrices(dim=$50\times 50$). For that, I have 3 lists, each of size 1 by 10,000 ...
1answer
37 views

### to print the result in two tables

I have this code ...
0answers
54 views

### For loop to define a Matrix

Suppose I have a matrix, Mat = MatrixForm[{{1.5, 2.83034}, {1.50476, 2.82655}}] I need to define parameters such that in the matrix 'i'th component is 'Lambda' ...
0answers
60 views

### Is this the most idiomatic way to convert matrix into dataset?

Is this the most idiomatic way to convert matrix into dataset? (for Mathematica 10 or higher) I was kind of hoping this would work: ...
2answers
69 views

### Different Value for LU Decomposition [duplicate]

When I try to LU decompose a matrix m, I get a different result in mathematica than an online calculator. Mathematica also gives me values that is different from my own derived values for the elements ...
2answers
88 views

### Calculating the probability of hitting, Fisher linear discriminant

I have 4 data matrix, which are described two parameters. (M1, M2, M3, M4). So I made transition from base parameters to principal components and displayed them in ...
1answer
134 views

### Creating a diagonal matrix from from a vector [closed]

I try to create a function that create a diagonal matrix in which the diagonal are: $\qquad 1,a,a^2, \cdots,a^n,1,a,a^2, \cdots,a^n$ Here is my attempt: ...