Tagged Questions

Questions on the manipulation of matrices in Mathematica.

learn more… | top users | synonyms (1)

21
votes
2answers
2k views

How to form a block-diagonal Matrix from a list of matrices?

like this: I know join[...] works, but it is a bit troublesome for multiple matrices.I tried DiagonalMatrix[...], but DiagonalMatrix can only form matrix from a list of elements.
3
votes
3answers
238 views

How to transform and swap columns of this matrix in a simple way? Version 2

So, earlier today I asked the question How to transform this matrix & swap its columns in a simple way? and was given useful and elaborated answers. Now, I'm still not used to the "Array", ...
0
votes
2answers
598 views

How to get complement from two matrices?

This is a special case of my question How to do nor on matrices? ...
3
votes
4answers
348 views

How to transform this matrix & swap its columns in a simple way?

I would like to transform matrix $\mathbf A = \begin{pmatrix} a&b&i&j\\ c&d&k&l \\ e&f&m&n \\ g&h&o&p \end{pmatrix}$ into matrix $\mathbf B = ...
0
votes
1answer
156 views

How to do nor on matrices?

Supose I have matrices a b and c like a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; b = {7, 8, 9}; c = {{1},{4},{7}}; I want to get ...
9
votes
2answers
2k views

Badly conditioned matrix (General::luc)

With some matrices I am receiving the following message ...
6
votes
1answer
5k views

Quick Hessian matrix and gradient calculation?

I am absolutely new to Mathematica and I actually want to try implementing a little optimization method . Long story short assuming I have a predefined two-variable function f(x,y) I want to ...
2
votes
1answer
204 views

Can I reduce a matrix inequality such as $\mathbf x^\prime\mathbf A\mathbf x > \mathbf x^\prime\mathbf x$?

I'm new to Mathematica. When I do linear algebra, I wonder if I can have an inequality such as $\mathbf x^\prime\mathbf A\mathbf x > \mathbf x^\prime\mathbf x$, where $\mathbf x$ is a column vector ...
0
votes
1answer
155 views

Discrete 3D plots of median ratios of two 2D matrices of lists of values

Lets say I have 2 2D arrays where each cell contains a list of values: Example: ...
0
votes
0answers
47 views

Inverting a matrix [duplicate]

Possible Duplicate: Why does MatrixForm affect calculations? I am facing a strange behaviour from Mathematica when asking it to invert the following matrix: ...
3
votes
1answer
164 views

Efficiently finding the maximum value of a column in a matrix

Imagine I have a matrix of the following form: TestArray = $((a_1,b_1,...),(a_2,b_2,...),(a_3,b_3,...),...)$, where a specific example might be: TestArray = ...
1
vote
3answers
377 views

More than one expression in the Table[] command?

I would like to construct a Matrix using the Table[] command. The issue is that I would like to use more than one expression for it. What I need to obtain is something like this : ...
5
votes
1answer
216 views

How to define and compute various properties of a variable size matrix

I have a rather simple question, but I have not been able to figure out how to implement a solution in Mathematica. I would like to define a variable size square matrix, say an N x N matrix A, whose ...
2
votes
2answers
205 views

How can I shift the frame ticks to the corner of each element-cell in a Matrixplot?

I am using the following code,to create a Legend for my plot. I would like to shift (or re-position) the frameticks to the corner of each of the cell-elements instead of being in their middle. I ...
0
votes
0answers
69 views

Trying to access element of a matrix [duplicate]

Possible Duplicate: Question about MapThread and Dynamic I'm trying to extract element of a matrix. Let's suppose that the matrix is ...
3
votes
2answers
326 views

Dynamic matrix multiplication

I have the following problem: I want to multiply two matrices and sum them to another matrix C. A.B+ 2B Easy! The matrix A varies as a function of three inputs a,b and c. The second matrix, B, is a ...
10
votes
2answers
321 views

Compiling LinearSolve[] or creating a compilable procedural version of it

Earlier today I had a discussion with a representative at Premier Support about the 2 questions I've asked here over the past couple of days: Seeking strategies to deploy a function securely ...
8
votes
2answers
258 views

Correct way to generate large data sets (i.e.forward yield curve )

I would like to generate a set of forward yield curve matrix of size 1000 x 100. First I defined my SparseArray of 1000 x100: ...
1
vote
1answer
102 views

How can I find the row differences of a matrix?

How can I compute the row differences of an m x n matrix to obtain an m-1 x n matrix; that is, given how do I obtain
0
votes
3answers
409 views

How can I fill in a matrix at every iteration of a Do loop?

I have a matrix whose dimensions are 26x26x3. For my assignment I have written a program which is using a Do loop (maxx=maxy=10,maxz=2): ...
3
votes
3answers
303 views

Correct way to populate a DiagonalMatrix?

I would like to create a series of correlation matrices that starts with : sensMat[[1]] = DiagonalMatrix[ { 1,1,1,1,1 } ]) // MatrixForm and iterates in 0.1 ...
5
votes
1answer
1k views

Problem with plotting eigenvalues

I want to plot the eigenvalues of a matrix which is dependant on a parameter (well, actually I want to plot a tight-binding electronic band structure). The dimension of the hamitonian matrix is ...
1
vote
3answers
790 views

How do I combine the data from two tables according to a rule of my own devising?

I have two matrices a = m x 5 and b =m x 5 (m is large, say 1,000) which are already sorted as below: How to generate a new matrix c = m x 5 which consists: Column 1: exact replica of Column 1 ...
-1
votes
2answers
392 views

Correct way to compare arrays and do conditional evaluations

I would like to compare two arrays a=: and b= and get: using: (b/.(b_?Positive->a+b))//MatrixForm but this doesn't seem to work? Can ...
0
votes
3answers
928 views

Correct way to remove matrix columns?

I start off with m = 1000 x 5 matrix, and I would like to remove first column to get 1000 x 4 matrix and repeat again for ...
-2
votes
1answer
118 views

Can Depth be used as an equivalent for MatrixQ?

Given an expression x, are the following two statements interchangable with no exceptions? Depth[x] - 1 == 2 ...
-1
votes
1answer
441 views

How to efficiently fill in matrix values?

I would like to efficiently fill in or assign values to matrix m: m={ {a[1,1],a[1,2],a[1,3],a[1,4]}, {a[2,1],a[2,2],a[2,3],a[2,4]}, {a[3,1],a[3,2],a[3,3],a[3,4]}, ...
2
votes
3answers
203 views

MatrixForm explanation as why row extract is displayed as a column?

I have a 5 x 5 matrix: cdsSpread5yrs = But after doing a row extract, why is it displaying as a column? ...
2
votes
1answer
409 views

RowReduce: Solving for the resource vector (a, b, c) in Augmented Matrix

Here are two examples: RowReduce[{{3, 1, a}, {2, 1, b}}] evaluates to {{1, 0, a - b}, {0, 1, -2 a + 3 b}} but ...
0
votes
2answers
371 views

Matrix Plot – Little Exercise

Hi there, mathematicians. I'm not very good at coding plots in Mathematica, so I was hoping that one of you could help me solve a problem I'm having. I have the following matrix plot: ...
9
votes
2answers
818 views

How to transform a 3D image by an affine transformation matrix

I have a question concerning Image Processing: I have a stack of images, which I can compose to a 3D image using Image3D. Additionally I have a 4x4 affine transformation matrix. I would like to ...
4
votes
2answers
318 views

Rearranging a matrix

I would like to convert a matrix which has a structure like this: {{"A", 10, "D", 1},{"B", 3, "A", 2},{"C", 7, "B", 3},{"D", 6, "C", 4}}//MatrixForm//Print; ...
9
votes
1answer
282 views

Verifying and deriving basic (block) matrix identities

How can I use the new symbolic matrix/tensor capabilities to verify matrix identities, such as (1) or (2) Even better, how can I ask Mathematica to derive expressions for X, Y, Z, and U like ...
3
votes
3answers
189 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 ...
4
votes
2answers
572 views

Exact cover solution

Is it possible to get a exact cover solution(s) and/or number of possible solutions in Mathematica?
1
vote
0answers
297 views

Matrix algebra vs. PrincipalComponents and Varimax/Oblimin

Using matrix algebra I can calculate loadings and scores from the covariance matrix (data matrix is column centered): ...
5
votes
1answer
189 views
5
votes
2answers
437 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: ...
1
vote
1answer
327 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 ...
4
votes
2answers
1k 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 ...
7
votes
3answers
757 views

How to manipulate gauge theory in Mathematica?

I want to know if there is a way of typing into Mathematica an expression like the following, $$\epsilon^{\mu \nu \lambda} f^{abc} A^a_\mu A^b_\nu A^c_\lambda + g\epsilon^{\mu \nu \lambda} A^a_\mu ...
7
votes
4answers
193 views

Generating all matrices with 1 (possibly) replaced by -1

I have a matrix $M$, whose dimension I am unsure of, which has only $\lbrace0,1\rbrace$ entries. I would like to generate all the possible matrices that result from changing (some subset) of the $1$'s ...
3
votes
3answers
230 views

Are table headings functional?

Are table headings for aesthetics only? If I have: ...
1
vote
1answer
153 views

Optimization of correlation calculation

How can I make the following line of code run faster? Is there a way to do this calculation as a matrix vs vector than vector vs vector? In the code below, f is a ...
2
votes
1answer
507 views
2
votes
1answer
352 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
246 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
431 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. ...
0
votes
0answers
35 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
226 views

How to Sort on row by row basis?

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