# Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

2,364 questions
Filter by
Sorted by
Tagged with
368 views

### Need Help Writing (a Pascal) Matrix in Mathematica

I want to write a function $f[n]$ in Mathematica which gives me an $n\times n$ lower triangular Pascal matrix with a row of zeros in between each nonzero row. That is, I want the matrices \begin{...
1k views

### Exact cover solution

Is it possible to get a exact cover solution(s) and/or number of possible solutions in Mathematica?
266 views

### What's wrong with this code to create a matrix?

Here is my code: ...
2k views

### Sort matrix by columns and rows without changing them

I would like to sort a matrix in descending order first by the total of each column, then by the total of each row, but without changing their content. For example, if I had: ...
410 views

### A lot of matrix multiplication

So I have a set of 15 $4\times 4$ matrices which I call $X_i, (i=1,2..15)$ and a set of 6 $4\times 4$ matrices which I call $y_j, (j=1,2...6)$. Now I have to calculate $(X_i y_j)-(y_j X_i^*)$ for ...
6k views

### I need to multiply a series of matrices

I need to perform a dot product on a large number of 2 x 2 matrices that I have defined to differ by even/odd subscripts (Ex: D-odd=x but D-even=y). The $\Pi$ function will not work because it does ...
2k views

41 views

### Why isn't the matrix product computed? [duplicate]

Possible Duplicate: Why does MatrixForm affect calculations? I have the following input: http://wstaw.org/m/2012/11/15/geogebra4.png Why is the matrix not computed, giving me a $2 \times 2$ ...
848 views

### How to Sort on row by row basis?

Say I have matrix how to sort on row by row basis to get:
595 views

### How to do conditional matrix division when elements are a combination of zero and real numbers?

I tried to divide two large matrices DLand PL of size 100,000 x 5 each and they look like this, DL= and PL= By using conditional function: ...
726 views

...
1k views

### How to take matrix elements as input to another matrix or loop?

Say I have matrix tmp1 of size 1000 x 5 (shown is just a small section for illustration purpose), consisting of real numbers and 0: How can I iteratively take every non-zero real number elements and ...
153 views

### Matrix conditional operation

Say I have a matrix of: tmp1 = 5; tmp2 = 5; tmp3 = RandomChoice[{0, 1, 2, 3, 4, 5}, {tmp1, tmp2}]; MatrixForm[tmp3] How to do a conditional operation of elements ...
311 views

### How to get a sub range of a larger matrix?

This should be an easy question but I only found a partial solution using All. Say I have a matrix A = 1000 x 5, how to get only a part of that matrix, say B = n x ...
507 views

### Is there a way to do conditional matrix loop using 'continue'

I have the following: ...
329 views

### Rearranging a biclustered matrix

I currently have a $77\times 38$ matrix, and I have used a clustering algorithm to cluster the row data and column data. The rows and columns of my matrix correspond to a list of country codes (not in ...
2k views

### Matrix Multiplication Modulo 2

I would like to perform matrix multiplication modulo 2. Hence, instead of the usual: A.B I did: ...
393 views

### How to do equality check of a large matrix and get the corresponding index position?

Say I have a matrix A = 1000 x 5, and I want to compare it's first element (uppermost top left) to each of the 5 elements in the first column of matrix B of size 5 x 5. Whenever the first time the ...
645 views

### using Mathematica's matrix multiplication in C++

Is there any way that I can utilize Mathematica's matrix multiplication in a C++ program? I'm making a 3D graphics engine (for class) in C++ and I would really like to use Mathematica for all of my ...
254 views

### Mathematica Complains about Non Symmetric Covariance matrix, when it's not the case

I was doing some fitting with Mathematica7 using NonlinearModelFit. It's quite long the program to do the fit and that's why I am not displaying here ... It goes ok, and I can get the fit parameters ...
236 views

### how to get modify the following correlation matrix with a specific list of financial prices?

The following takes the last 5 members of the Dow Jones index and plots the correlation matrix of the last 5 years of daily prices: ...
1k views

### Tridiagonal matrix for any n

I'm pretty new to Mathematica and I need to figure out how to create a $n\times n$ tridiagonal matrix for any $n$. I don't have the slightest clue where to begin. Edit: got this far, not sure how to ...
658 views

### How do we solve N-Rooks variation using primes?

Using a $p_n$x $p_n$ matrix, how can we solve the N-Rooks problem to find a prime in every row and column? ...
544 views

### Can mathematica simplify an expression setting simplified answer equal to zero?

Basically I want to reduce something like: Subscript[P, 4] - Subscript[P, 5] == Subscript[R, 4, 5]* Subscript[i, 4, 5] when only one of them is known (...
735 views

### Creating a matrix from the output of a variable inside a for loop

I would like to enter the results of the following loop inside a matrix as its elements: ...
2k views

### How to calculate FDCT

I'm new to Mathemtica and I'm trying to calculate Discrete Cosine Transformation FDCT. I found the FourierDCT built-in function, but not DCT, so I need to implement it. I have tried couple of ideas ...
1k views

### Calculating an exact orthogonal modal matrix in Mathematica

I can calculate the modal matrix of a matrix A using the command JordanDecomposition[A][], and a decimal approximation of the orthogonal (or normalised) modal ...
2k views

### Subspaces in Mathematica

I'm working on a research project and I need to learn how to use Mathematica to calculate subspaces. Specifically I plan to solve the following operations and I would greatly appreciate if you could ...
364 views

### Printing Block Matrices

I have a 2D matrix, such as: d=2; M=Array[a, {d^2,d^2}]; and I would like to print it in a way which emphasizes its dxd block matrix structure. If ...
3k views

### Eigenvalue / Eigenvector Calculation

I'm currently trying to compute the three smallest eigenvectors for a 34 by 34 matrix. While I was expecting this to take some time, Mathematica has been running for the past 3 hours, which seems ...
232 views

### Test First row of matrix

What is a good way to test the first row of a Matrix to check if one of the values equal a value. For instance, In this example, I want to get vector in the second row that has the bigger value in the ...
670 views

### Loop and do operations on Matrix, then graph the results

I'm trying to do some operations to a matrix in a loop, and then I want to graph the results. The results are pair of numbers. Can I store the results of each iteration on "something" and the use ...
1k views

### Total Variation Distance of probability matrix

How can I calculate the Total Variation Distance of a transition Matrix? is there any built in function? I've searched all documentation and haven;t found anything. ** More information: Let me try ...
551 views

### Transform x-scale of data for e.g. MatrixPlot

I have to transform in a nonlinear way the x-scale of some data for a MatrixPlot (or ReliefImage or ...
378 views

### Numerical comparisons of matrices

I have a matrix which should be equal to a null matrix. However due to the numerical precision, a brutal equality test with a matrix initialized with zeros does not work. How should I perform the ...
2k views

### stationary distribution of a transition matrix

How can I solve the stationary distribution of a finite Markov Chain? In other words, how can I estimate the eigenvectors of a transition matrix?
5k views

### Mathematica won't give eigenvectors but Wolfram Alpha will? What am I doing wrong?

If I ask Mathematica to find the eigenvectors and eigenvalues of the matrix: ...