Questions on the manipulation of matrices in Mathematica.

learn more… | top users | synonyms (1)

2
votes
1answer
264 views

How to modify a matrix to satisfy a special condition?

I have matrix like this: How do I modify this matrix to make it satisfy the following condition: For each element {i, j} in the matrix the sum of the elements of row i must be equal to the sum ...
4
votes
6answers
233 views

Sorting Matrix elements

I have matrix in as shown, consisting of real numbers and 0. How can I sort it to become out as shown? ...
5
votes
3answers
369 views

How to sum matrix elements based on finding the first (and second) non-zero elements of each row?

I have a matrix: I would like to sum all the first non-zero elements of each row so that I get a value of $$25.5317 + 8.85471 + 6.90018 + 32.9436 + ... $$ and so on and simply ignore zero rows. ...
1
vote
1answer
262 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: ...
0
votes
0answers
34 views

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

Possible Duplicate: Why does MatrixForm affect calculations? I have the following input: Why is the matrix not computed, giving me a $2 \times 2$ matrix?
1
vote
1answer
207 views

How to Sort on row by row basis?

Say I have matrix how to sort on row by row basis to get:
1
vote
2answers
561 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 ...
2
votes
3answers
332 views
0
votes
1answer
526 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 ...
1
vote
1answer
489 views

Matrix Multiplication Modulo 2

I would like to perform matrix multiplication modulo 2. Hence, instead of the usual: A.B I did: ...
0
votes
2answers
224 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 ...
6
votes
1answer
572 views

vectorial ODE in mathematica with matrix exponentials

I want to solve the following equation in mathematica : DSolve[{X'[t] == A.X[t], X[0] == ( {{0},{0}} )}, X[t], t] It is a system of 2 ODEs coupled by the matrix A, ...
3
votes
0answers
197 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 ...
0
votes
1answer
160 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: ...
2
votes
1answer
431 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 ...
2
votes
1answer
251 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: ...
1
vote
0answers
228 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 (...
1
vote
2answers
644 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 ...
1
vote
1answer
525 views

Calculating an exact orthogonal modal matrix in Mathematica

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

How to extract RGB arguments as a list

Although the following lines of code work fine they are very awkward. My questions are below a = RGBColor[1, 0, 0] b = RGBColor[0, 1, 0] Is there a more compact ...
4
votes
1answer
256 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 ...
6
votes
2answers
1k 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 ...
2
votes
5answers
144 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 ...
2
votes
2answers
421 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 ...
4
votes
2answers
460 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 ...
4
votes
2answers
236 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 ...
2
votes
1answer
187 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 ...
3
votes
1answer
675 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?
5
votes
1answer
1k 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: ...
2
votes
1answer
1k views

Creating a random normal matrix

I would like to create a random matrix with the constraint that the matrix must be normal, i.e. the matrix and its Hermitian conjugate must commute. I would create a random matrix "without ...
12
votes
4answers
317 views

Inputting a big structured matrix in Mathematica

Hi this is my first post and this is a problem that has bothered me a lot. Suppose we have the $2012\times2012$ square matrix: ...
12
votes
1answer
416 views

How to extract and replace submatrix of a doubly-periodic matrix?

How can I effectively extract and replace a rectangular subpart of a toroidal matrix, i.e. one where boundaries are connected at opposite ends? Since the submatrix can overhang the edges, a simple ...
2
votes
3answers
701 views

Finding eigenvalues of a $1500\times1500$ matrix

I need to find the eigenvalues of a $1500\times1500$ real symmetric matrix given by $A_{i,i+1}= A_{i+1,i}=-1$ and also $A_{1,N=1500}=-1$ (this is because of a periodic boundary condition used) and all ...
4
votes
4answers
2k views

How to convert equation to vector (matrix) form?

How can I convert expression a1*u1+a2*u2+a3*u3 to the vector form of dot product A.U, where ...
19
votes
4answers
2k views

Why does MatrixForm affect calculations?

This is a really newbie question, but it has me confused. Why does this code work without // MatrixForm and doesn't work with ...
9
votes
2answers
2k views

How to get Matlab data imported with the same dimensions?

I have some Matlab image data with the following dimensions (output is from Matlab): >> size(im) ans = 86 86 3 45 The data imports just fine ...
13
votes
3answers
990 views

Mathematica for linear algebra course?

I'm taking a linear algebra / matrix theory course and we are free to use any software we want, and will be "expected to use MATLAB or an equivalent" for homework. The professor and textbook (Applied ...
1
vote
1answer
534 views

Is Mathematica matrix multiplication with its inverse wrong? [duplicate]

Possible Duplicate: Why don't * and ^ work as I expected on matrices? When I enter this ...
1
vote
2answers
457 views

How to Solve or LinearSolve $A = I$ matrix equation?

I'd like to solve this equation for $A = B$ where $B = I$, which represents 3 systems of 3 linear equations, for $a, b, c, d, e, f$, without writing LinearSolve 3 ...
3
votes
4answers
154 views

Pack Solve results into a vector

I am currently using a really easy function to get the eigenvectors of a corresponding eigenspace: ...
10
votes
3answers
901 views

Correcting a correlation matrix to be positive semidefinite

Does Mathematica have a way to "fix" a correlation matrix that is not positive semi-definite? I looked through the documentation and search the internet but could not find anything.
6
votes
1answer
496 views

How to turn a random graph into a matrix

I have constructed a random graph with Mathematica using the RandomGraph command. Now I would like to convert this graph to a matrix, but I don't know how. The ...
1
vote
2answers
223 views

Symbolically associate vectors and their norms

I am wondering how to handle the following situation: I do have vectors of known dimension that I would like to handle symbolically. I suppose I can do something like ...
4
votes
2answers
160 views

Standardizing a coset table via matrix manipulation

Suppose we have a group $G$ and a subgroup $H$. A coset table encodes the permutation representation of $G$ on the right cosets of $H$. When we want to use these coset tables in calculations, it is ...
5
votes
4answers
542 views

Swap two entries in a matrix

Is there a nice, simple script one can use to swap two entires in a matrix? For example, suppose we have the matrix below: $A=\begin{pmatrix}2 & 4 & 1\\ 3 & 1 & 2\\ 4 & 3 & 1 ...
8
votes
1answer
356 views

Efficiently Constructing Rank One Approximations for a Matrix using SVD

Suppose I have a $m\times n$ matrix $A$ (real for simplicity). Then SingularValueDecomposition[A] yields 3 matrices $U$, $\Sigma$ and $V$ such that $A = U\Sigma ...
1
vote
1answer
319 views

How do I use a matrix that has a variable?

I seem to be getting an error whenever I try running this piece of code. Matrix12[n_] := {{1, 0}, {0, {\[Kappa]1[n]}/{\[Kappa]2[n]}}} I've already defined the ...
2
votes
3answers
1k views

Passing a matrix as a function argument

I am trying to do the following: ...
5
votes
1answer
466 views

Finding the characteristic polynomial of a matrix modulus n

Given a square matrix, is it possible to calculate its characteristic polynomial modulo n? Unfortunately, this function ...