Stack Exchange Network

Stack Exchange network consists of 175 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

Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

3
votes
2answers
173 views

The multiplication of list of matrices

I need to multiply 3 lists of matrices (b.a.b) as the following code ...
4
votes
0answers
48 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 ...
4
votes
5answers
420 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 ...
2
votes
4answers
153 views

Dot product result has wrong dimension

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 ...
2
votes
2answers
66 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 ...
1
vote
1answer
36 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 ...
3
votes
1answer
31 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: ...
0
votes
1answer
35 views

constructing Matrix from coefficients of solution & assigning 0 for empty Cells

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 ...
2
votes
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 ...
2
votes
0answers
27 views

Reduce returns false on equation solvable by LInearSolve

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: ...
2
votes
1answer
59 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: ...
0
votes
0answers
50 views

Different Outputs When Calculating Within a Table and Seperately [closed]

I have a matrix which looks like this: $$\begin{pmatrix} a & e & 0 & 0 \\ 1 & b & 1 & 0 \\ 0 & 1 & c & 1 \\ 0 & 0 & 1 & d \\ \end{pmatrix}$$ where $\{ ...
0
votes
0answers
38 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. ...
0
votes
0answers
33 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 ...
4
votes
1answer
72 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 ...
0
votes
1answer
49 views

A transfer-matrix approach for multi-barriers [on hold]

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 ...
1
vote
2answers
51 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: $$\...
0
votes
1answer
62 views

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

Suppose I have 20 Matrices: Mat[1], Mat[2],...,Mat[20]. 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.
4
votes
1answer
68 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 ...
1
vote
2answers
83 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 ...
0
votes
0answers
56 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 ...
7
votes
3answers
221 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: ...
2
votes
4answers
139 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 ...
0
votes
2answers
126 views

Constructing a special square matrix

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

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

I am getting these strange eigenvalues of this simple looking 4-dimensional matrix: ...
0
votes
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 ...
0
votes
1answer
73 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
6
votes
2answers
147 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 ...
0
votes
1answer
58 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 ...
0
votes
1answer
43 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 ...
2
votes
2answers
39 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. ...
0
votes
2answers
78 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? ...
0
votes
0answers
109 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 ...
0
votes
1answer
46 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. ...
4
votes
1answer
179 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, ...
2
votes
2answers
67 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 ...
4
votes
3answers
212 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 ...
2
votes
1answer
32 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 ...
0
votes
1answer
34 views

to print the result in two tables

I have this code ...
0
votes
0answers
44 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' ...
4
votes
0answers
53 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: ...
1
vote
2answers
50 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 ...
0
votes
2answers
80 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 ...
1
vote
1answer
68 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: ...
0
votes
0answers
29 views

To assign an array to a function

// Pre-defined parameter kS = 2*(\[Pi]*NefS)/LambdaSS; Here, NefS is a function of LambdaSS. The matrix m (i,j) defined corresponding value of NefS (jth ...
0
votes
2answers
69 views

How to calculate $(X^tX)^{-1}X^tY$? [duplicate]

This is MatrixForm[ {{1., 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1.5, 1.5, 1.5, 2, 2, 2.2, 2.4, 2.5, 2.5, 2.8, 2.8, 3, 3, 3.2, 3.3}}] $X^t$ ...
0
votes
0answers
32 views

Reshaping list of matrices

I have a list of square matrices $A_i$ as follows $$ \left(\begin{matrix}A_1 & \ldots& A_n \\A_{n+1}&\ldots &A_{2n} \\ \vdots & \ddots & \vdots \\ A_{(k-1)n+1} & \ldots &...
2
votes
1answer
31 views

Performance Tuning: Construction of Matrix with Summations

I am trying to solve an eigenvalue problem of a large matrix. The issue is that it takes too much time to construct this large matrix. This is the code that I built: ...
0
votes
2answers
76 views

Generating a large sample of 10 x10 symmetric matrices

I am currently having some issues with Mathematica. I have a 10x10 symmetric matrix with the diagonal entries removed and labeled as "z". I now want to create a command that generates a sample of ...
0
votes
2answers
92 views

Create special matrix

I need to construct special matrix in mathematica which is given in the following image