Questions on the manipulation of matrices in Mathematica.
0
votes
1answer
932 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
133 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
112 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
42 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
69 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
153 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 :
...
4
votes
1answer
105 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
142 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
64 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
237 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 ...
1
vote
1answer
135 views
How do I compose two functions (matrices) in Mathematica? [closed]
I'm new to Mathematica. I've been reading the 'Documentation Center' but can't find a clue about composing two functions which in my case are matrices.
Here's the setup. let ...
0
votes
0answers
62 views
please help to me, Where is my mistake? [closed]
e = {{v, -37925.9}, {-37925.9, s}}
v = (37925.9 - 12.74 x)
s = (7585108 - 15029 x)
Solve [e == 0 , x ] please help to me, Where is my mistake?
10
votes
2answers
200 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
196 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
80 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
185 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
236 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 ...
0
votes
0answers
83 views
Not getting the required eigenvalues [closed]
I'm trying to use Mathematica to show that the eigenvalues of $U$ are $\pm\dfrac{1-i}{\sqrt{2}} $, where
$U = (I + T + iS)(I - T- iS)^{-1}$ where $ S = \left( \begin{matrix}
1 & 1 \\
1 ...
5
votes
1answer
332 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
223 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
145 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
183 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
112 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
188 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
148 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?
...
1
vote
1answer
112 views
RowReduce Problem
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
227 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
538 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 ...
8
votes
1answer
163 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
135 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
313 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
173 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
2answers
185 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
250 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 ...
3
votes
2answers
256 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 ...
4
votes
3answers
339 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
170 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
165 views
1
vote
1answer
130 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
215 views
2
votes
1answer
123 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
189 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
209 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
29 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
101 views
1
vote
1answer
136 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:
...
2
votes
1answer
392 views
1
vote
2answers
231 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 ...
0
votes
2answers
100 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 ...
0
votes
2answers
140 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 ...