Questions on the manipulation of matrices in Mathematica.

learn more… | top users | synonyms (1)

12
votes
2answers
140 views

Better way to test that a matrix is upper-triangular?

Today, I got to thinking about how to test that a matrix was upper-triangular. So I had a try at it. Algorithm $\quad \quad a_{ij}=0 $ Or $i \leq j$ $\Rightarrow$ $True$ My solution is ...
9
votes
3answers
864 views

An inverted pyramid

I want to draw a pyramid approximately like this ...
2
votes
3answers
99 views

How to multiply specific columns in a matrix of data?

So I need to make a plot of some ~2000 data points I have from a spreadsheet. I'm able to import the data just fine, it stores it like so sundat ...
3
votes
0answers
41 views

Why such iteration leads to fractal? [migrated]

I saw a piece of codes like: ...
6
votes
3answers
208 views

Efficient method to generate Tridiagonal 50 by 50 Matrix? [duplicate]

I'm looking to generate a tridiagonal 50x50 matrix, ideally without using loops. Suggestions on most efficient code for this?
2
votes
1answer
88 views

Why does LinearSolve return the transpose of the answer matrix?

I am trying to solve an equation of the form $dv=F\cdot dV$ where $dv$ and $dV$ are matrices derived from the row vectors $dx$, $dy$, $dz$ and $dX$, $dY$, $dZ$ respectively. If it helps, $F$ is the ...
2
votes
3answers
102 views

Syntax of transpose etc [closed]

This is a simple question: {{0, 1}, {0, 2}, {0, 3}}*Transpose[{{0, 1}, {0, 2}, {0, 3}}] returns an error in Mathematica but works perfectly fine in Wolfram Alpha. Can someone help me? Thanks so ...
8
votes
4answers
260 views

Replacing matrix values

I want to find the n largest values in a matrix and replace all others with zero. The solution I found uses ReplaceAll and becomes very slow as the size of ...
6
votes
3answers
81 views

How to create a block diagonal matrix by repeating a submatrix $n$ times?

If there is a submatrix, let's call $P$: $P=\begin{pmatrix} 1 & 1 \\ 1 & 1 \end{pmatrix}$ And I want to have $n$, let's say $n=2$, such submatrices placed on the diagonal. The result is ...
3
votes
0answers
56 views

Fast principal component analysis

I'd like to speed up a principal value value analysis. The data contains a large set of vectors with a large dimension. Both are in the range of 1000. I want to obtain the loadings matrix for further ...
0
votes
1answer
47 views

Combining lists in a matrix

So I have a list of data A={1.1,1.2,1.3,1.4,6.1} etc and B={2.5,2.6,2.7,2.8,2.9} I need to combine the lists into a matrix C ...
3
votes
1answer
79 views

Efficient Dyson series implementation

I'm trying to implement a Dyson series \begin{array}{lcl} U(x,x_0) & = & 1 + \int_{x_0}^{x}{dy_1V(y_1)}+\int_{x_0}^x{dy_1\int_{x_0}^{y_1}{dy_2V(y_1)V(y_2)}}+\cdots \\ & &{} + ...
2
votes
0answers
35 views

CUDALink Error: A CUDALink kernel timed out?

I'm following the CUDALink tutorial [ http://reference.wolfram.com/language/CUDALink/tutorial/Introduction.html ] and everything is going fine until I get to the part that calls CUDADot on the ...
0
votes
6answers
180 views

How to build a game board [duplicate]

I have - rather lazily - constructed a chessboard like this: ...
3
votes
2answers
180 views

Order of eigenvectors [duplicate]

I have a matrix A = {{5, 4, 2}, {4, 5, 2}, {2, 2, 2}} The eigenvalues are 1, 1, 10 and I need to find the eigenvectors. ...
-2
votes
0answers
20 views

Matrix multipication [migrated]

Is this matrix multiplication is possible? Microsoft mathematics gives me a answer for it? How it could be a correct? If we need multiple two matrix, number of rows and columns should be equal. So how ...
1
vote
1answer
57 views

m equations and n variables. Reducing using Mathematica

I have six equations and thirteen variables. I would like to reduce it to seven free parameters. I used Reduce to solve it but it is taking really long (one full day and no output yet) and I think ...
0
votes
0answers
24 views

What are the upper bound and stability conditions for the following simple linear system [migrated]

Consider the following linear system $$\dot{x}=\sum\limits_{i=1}^{m}{{{\alpha }_{i}}}\left( t \right)\cdot {{A}_{i}}\cdot x \quad (1) $$ where, $x\in {{\mathbb{R}}^{n}}$ represents the state vector, ...
2
votes
3answers
149 views

Hypergeometric function with a matrix argument

I am looking for the evaluation of a Hypergeometric function with a matrix argument as for example in Ploev and Edelman or as showcased in this Wikipedia article. From what I understand from ...
3
votes
3answers
102 views

Solving determinant of a Kronecker product of matrices gives a numerical error - why?

I am doing the following steps (code at the end of the post): I start with a 2x2 matrix (smatrix), which is a function of a single variable (u2). I want to set the determinant of this matrix ...
3
votes
2answers
228 views

How to create a 'shortest-path link matrix'?

I am currently struggling with a problem in Mathematica. I have a randomly generated weighted Barabasi-Albert graph and a corresponding demand matrix of the same size. I'm generating the graph with ...
4
votes
3answers
145 views

Split matrix by all-zero columns

Below is my input: mat = {{0, 0, 0, 0, 0, 1}, {1, 0, 0, 1, 0, 1}, {0, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1}, {1, 1, 0, 1, 0, 0}, {0, 0, 0, 1, 0, 1}}; ...
13
votes
4answers
646 views

“Indexing” a vector

I need to "index" a vector according to the first occurence of its distinct elements. I have written ...
2
votes
2answers
89 views

Making a conjecture concerning a certain upper-triangular matrix

I have searched for commands which will let me to create matrices and do matrix operations, but I don't know how to apply Mathematica to the following exercise. Make a conjecture for the result of ...
0
votes
0answers
93 views

Spectral Clustering

I am interested in the following question: How is it possible to check whether an algorithm is working properly? However, this question is too general for the post and I'd like to restrict attention ...
1
vote
2answers
64 views

Block diagonal matrix [closed]

Suppose I have 4 matrices: A, B, C, D, and I want to form a block diagonal matrix from these sub-matrices, i.e. it would look like MatrixForm[{{A, B}, {C, D}}] ...
-2
votes
1answer
47 views

Compile Determinant [closed]

I would like to determine the determinant of a 4x4 matrix with the entries a[i,j] being functions of $i$ and $j$. I used Compile with code: ...
0
votes
1answer
60 views

Matrix consisting of the matrices [duplicate]

I need Dirac Matrix in my work. They consists of PauliMatrix and ZeroMatrix, which is: ZeroMatrix:=IdentityMatrix[2]-IdentityMatrix[2] I define Dirac Matrix as: ...
4
votes
2answers
183 views

Time-efficient creation of matrix

I have expressions like xx1=FF[1, 1] GG[1, 1] + FF[1, 1] GG[2, 2] + FF[2, 2] GG[2, 2] xx2=2*FF[1, 2] GG[1, 1] + FF[1, 1] GG[1, 2] + FF[2, 2] GG[2, 2] and I want ...
3
votes
2answers
102 views

Time-efficient manipulation (zeroing) of expression

I have huge matrices in the form of ...
0
votes
0answers
45 views

Question about the matrix operation [duplicate]

I was wondering if there is an automatic way to do this kind of matrix operation. For example, for a given matrix ...
8
votes
11answers
1k views

Ragged Diamonds

diamond[n_Integer] := Table[1, {#}] & /@ (Range[n]~ Join~Range[n - 1, 1, -1]) diamond[5] // MatrixForm How could a more functional, "tablefree", solution ...
1
vote
2answers
123 views

Sort matrix rows iteratively according to sum of some columns

I have a matrix say ...
3
votes
2answers
110 views

Inserting rows of one matrix into rows of another matrix sequentially

I have two matrices M1 and M2. Both have same number of columns but different number of rows. I want to make a new matrix M which should have 1st row form M1, second row form M2, third row form M1, ...
-2
votes
1answer
60 views

$SU(4)$ Structure constants in mathematica

How can I write a mathematica function which will output arbitrary structure constants of SU(4)?
3
votes
3answers
87 views

Matrix manipulation

Thank you for looking and answering this question. I am trying to create a new matrix from an old one. Meaning, I have a original matrix that's 20x20. I want to keep the first five lines of the ...
1
vote
1answer
65 views

How can I transform a matrix to a vector (vectorization)? [closed]

How can I transform a matrix to a vector in mathematica? $A=\bigg{(}\begin{matrix} a_1 &a_2\\a_3&a_4 \end{matrix}\bigg{)} \longrightarrow |a>>=(\begin{matrix} a_1 ...
0
votes
1answer
47 views

Map Elements of a list to be Index of matrix

I have a sublist from Tuples[{1, 2, 3}, 2], say for example L={{1,2},{2,1},{2,2}}, and a 3 x 3 matrix ...
3
votes
3answers
248 views

Matrix containing ellipse

I have to make a matrix which contains elements in an ellipse shaped region, but I need to make ellipse region in such a way that larger axis of ellipse is inclined with angle θ with horizontal. With ...
1
vote
2answers
83 views

Display Matrix of values with position [closed]

I want to find the table of values of $x^2 + y^2$ in steps of 1, from $0$ to $5$ for $x$ and $y$, together with the position $(x,y)$: something like this: I can only display the $x^2 + y^2$ value but ...
3
votes
2answers
220 views

Weird behavior when changing parts of matrix

I have this matrix: mat = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20}, {21, 22, 23, 24, 25}}; and here are its second row ...
10
votes
8answers
342 views

Forming an upper triangular matrix from the elements of a list

I asked this question before, but i was closed because it the question was not comprehensible enough. So i reworded it, hope that's ok. I have a list with 6 elements. ...
0
votes
0answers
50 views

how to solve an optimization problem in terms of matrices as the argument

How can I minimize an expression of the form a^T A a where a is a matrix. The following approach does not work if ...
1
vote
2answers
34 views

how to extract a matrix and a vector from a vector [duplicate]

I have a vector like this: V = {a*exp1+b*exp2+c*exp3, a*exp4+b*exp5+c*exp6, a*exp7+b*exp8+c*exp9} and I want to get : ...
1
vote
4answers
144 views

Finding maximum value with position from Table of values

I have this table of values, how do I find the maximum value? i.e. find $z_{max}(x,y)$ ...
1
vote
1answer
99 views

Mean squared error of two matrices

I want to compare two matrices. For this I use the mean squared error between them with the following code mse[mat1_, mat2_] :=(mat1 - mat2)^2 // Flatten // Mean ...
1
vote
0answers
75 views

Symbolic matrix calculus: What's new in Version 9

I have seen some of the related posts, which ask about doing matrix calculation on tensors unknown dimensions. One of the posts mentioned that version 9 has some capability, but it was concerned about ...
8
votes
4answers
291 views

Fast method to select matrix elements based on a vector of positions

There is an operation for which I have long wanted to find a better solution. Let: a be a matrix of dimensions $m\times n$ ...
1
vote
1answer
85 views

How to solve an operator form of an integral equation by iteration method?

How I can obtain the $n^{th}$ approximation of the following Operator form integral equation? $F(t)=A(t)+\int_0^tds B(s)F(s)$, where $A(t)=\bigg{(}\begin{matrix}t&0\\Cos(t)&1 ...
0
votes
0answers
59 views

I see error messages when I use LogLinear Plot but not when I use Plot

I have written an application with Manipulate that plots the results of several calculations. What I find strange is that when I have my application use ...