Questions on the manipulation of matrices in Mathematica.

learn more… | top users | synonyms (1)

1
vote
0answers
50 views

Mapping over two indices with a condition

How can I use Map over two indices with a condition? I am trying to calculate second derivative of an eigenvalue, $\lambda_i(x)$, of $n \times n$ matrix $M(x)$ ...
4
votes
1answer
74 views

How do I put matrices next to each other? [duplicate]

So I want to be able to put matrices "next to each other", or in other words if I have two matrices $A$ that is $n\times k$ and $B$ that is $n\times m$, I want to be able to create a matrix $C$ that ...
2
votes
1answer
161 views

Simple code to write differential equations in a matrix formulation

Is there a simple code to transform the following differential system equations : ...
2
votes
2answers
72 views

Problem with ArrayFlatten to concatenate matrix

I would like to concatenate 2 matrix : - the first which is a line of 2 elements - the second which is a matrix of 2-2 elements I use the following code : ...
7
votes
1answer
91 views

Count degrees of freedom of a polynomial

I want to count the independent degrees of freedom of a polynomial in three variables $(z_0,z_1,z_2)$. Therefore I take the coefficients of $f$ and compute the rank Jacobian with respect to the ...
4
votes
2answers
142 views

How to be more efficient/faster with this MatrixExp-vector multiplication?

I am looking for expertise that helps to improve speed of the code below. First, a little bit of background: There is some system of differential equations $\dot{\vec{m}}(t)=S(t)\vec{m}(t)$. In order ...
1
vote
0answers
62 views

Multivariate Path Construction using Sobol numbers

I am sharing my code,which I have tried to perform as per the instruction mentioned below. Please correct it so that I could get my output. Instruction: Use the first m dimensions of the Sobol vector ...
3
votes
1answer
143 views

Update or Animate an ArrayPlot or MatrixPlot?

I am trying to add new row or column or points to a 2D plot as I keep generating the values. The trick is by using this method I will not be required to store the big array or matrix and will be ...
4
votes
4answers
106 views

How to force MatrixPlot to differentiate distinct expr?

I thought MatrixPlot can differentiate different expressions in color until I found this: ...
1
vote
1answer
51 views

NMinimize error

I want to use NMinimize in the following way: ...
3
votes
3answers
234 views

How to convert an output of a matrix into a PNG image?

Using @m_goldberg's code I have created a matrix with the following command: ...
18
votes
1answer
456 views

Sparse Cholesky Decomposition

I am working with square matrices with a special form, which for large rank ($> 100,000$) would be best stored and manipulated as a SparseArray. I believe that ...
6
votes
3answers
236 views

How to create a general format of a matrix with specified entries?

I want to create a PNG picture of a matrix where its entries are the following: ...
1
vote
2answers
54 views

Bin data from an imported excel file by adding 5 elemets of y axis each [closed]

So i imported a file from excel and viewed it as a grid. but now i need to add groups of 5 elements from the y axis and plot them against every fifth entry from the x axis. Thanks Edit: Sorry about ...
7
votes
2answers
352 views

Finding a unitary matrix in Mathematica

I have the following equation : $ \tilde{B} = U B U^{\dagger} $ I also know both $ B $ and $ \tilde{B} $ , I just want to find the matrix U, that gives me the transformation. I tried using ...
1
vote
0answers
125 views

Speed matrix multiplications

I am trying to run this function ...
10
votes
3answers
467 views

How do you concatenate matrices? And how do you make block matrices?

This is pretty trivial to do in Matlab, but I have not seen a function for it in Mathematica. Here is how you can do it with Join and ...
1
vote
0answers
46 views

matrix multiplication performance

I would like to evaluate $$ f(x,y)=\sum_{i=1}^{N} X_i(x)\,Y_i(y) $$ where $X_i(x)$ and $Y_i(y)$ are known functions for all $i=1,\ldots,N$, and $x$ and $y$ are from the rectangle $[0,A]\times[0,B]$, ...
3
votes
1answer
34 views

Difficulty with LevelSpec. Product of empty set should be 1

I have a matrix newm = {{{}, {}, {-p}}, {{d}, {e}, {p}}, {{g}, {h}, {i}}}; MatrixForm[newm}; whose elements are lists. I would like to multiply the elements of ...
0
votes
0answers
115 views

LU factorization

Basically what I need to do is this: Write an algorithm that finds the LU factorization of the following matrix. The algorithm should perform the necessary elementary row operations to reduce A to U, ...
1
vote
2answers
123 views

Row-wise matrix multiplication

I have a matrix $A=\{a_{ij}\}$ of dimensions $n$ rows by $m$ columns, and I would like to multiply each row of the matrix by a constant $b_i$, $i=1,\ldots,n$, and store the result in the same ...
4
votes
1answer
203 views

What is the Mathematica equivalent for corr2?

What is the Mathematica equivalent for MATLAB's corr2, which gives the correlation coefficient of two 2D matrices?
1
vote
0answers
48 views

Sampling from an one-dimensional Wishart [closed]

I searched for a similar question but could not find one. My problem is sampling from an one-dimensional Wishart distribution. The Mathematica specification is ...
4
votes
1answer
112 views

Is it possible to find the vectors that span the nullspace of a large, symbolic matrix

My problem is composed of two parts, a large sparse matrix $L$ ($m$x$n$ where $m=10^3$, and $n=10^5$, with $10^7$ non-zero complex numbers), and a dense, symbolic matrix $F$ ($m$x$m$ where $m=10^3$), ...
0
votes
2answers
84 views

How can I use Nested For Loop to create matrix [closed]

I use this code but it doesn't work. ...
1
vote
1answer
96 views

Converting the subscript of matrix name to a variable

I want to change indices of matrix name during loop for creating different matrices. For example; ...
5
votes
1answer
118 views

How to do matrix calculus in Mathematica?

I would like to differentiate Ax with respect to A where A is a matrix. Now, obviously, I know the derivative is x but for more nasty expressions, is there a way to differentiate expressions with ...
2
votes
3answers
259 views

Eigenvalues of a large matrix

I want to compute the eigenvalues (and later the corresponding eigenvectors) of an $n\times n$ Hermitian matrix. For this I use {evs, vecs} = Eigensystem[matrix] or ...
7
votes
1answer
224 views

How write a new MatrixRank feature with symbolic computation

The current MatrixRank is a slight foolish without any capacity of symbolic computation ,feature of Mathematica, like this: ...
6
votes
0answers
74 views

How to instruct MatrixLog to work with singular matrices?

How to instruct MatrixLog to work with singular matrices by ignoring the zero eigenvalues (thus only acting on a subspace orthogonal to the matrix kernel)? I'm ...
2
votes
1answer
104 views

Is there a good way to check, whether a small value produced numerically is a symbolic zero?

I have a complicated 4x4 matrix and need to know the eigenvalues. I expect a zero eigenvalue for physical reasons. Giving numerical values first gives me an eigenvalue of $\mathcal O(10^{-15})$. Now ...
3
votes
2answers
130 views

Given a list of positions in a matrix, get elements within radius r

I have a n x n binary matrix like SeedRandom[1]; mat = RandomInteger[1, {9, 9}]; MatrixForm[mat] I want to create ...
6
votes
2answers
162 views

Grouping the list of numbers that have common.

I am working on some simple problem. It is like puzzle.. Let's say I have some list input={{1,1},{1,2},{1,3},{2,3},{3,3},{4,4}} Which means 1 can go and back to ...
7
votes
0answers
125 views

Examples of using Mathematica to solve matrix equations symbolically

Suppose we want to solve a linear system like $$\left\lbrack\begin{array}{cc}M& S\\ -S^\mathrm{T}&0 \end{array} \right\rbrack \left\lbrack \begin{array}{c} x\\y\end{array}\right\rbrack = ...
2
votes
1answer
79 views

Merge two matrices where one may be empty

In a loop, I want to merge two matrices A and B where B is sometime empty. Example: ...
2
votes
3answers
64 views

Having a function check a column and perform a task every time an entry satisfies a condition

So I have a matrix (technically a table) points = Table[{x, f[x]}, {x, Range[0, 2, .1]}]; Which gives something like this in matrixform \begin{array}{cc} ...
1
vote
2answers
142 views

Partitioned matrix operations

I have a $(2 \times 2)$ matrix whose elements are themselves $(2 \times 2)$ matrices (i.e., a partitioned matrix), e.g: $$ M = \begin{pmatrix} A & B \\ C & D \end{pmatrix}, \quad \quad ...
-1
votes
3answers
174 views

What would be a good way to implement index notation?

So I need to calculate a 3x3 rotation operator (basically a matrix). I have an index-notation expression, and I was wondering if with pre-calculated theta, K1, K2, and K3, could Mathematica compute ...
3
votes
3answers
183 views

Permutations of 0's and 1's in a lower-triangular matrix

For a given $n \ge 5$ create every $n$-by-$n$ matrix containing exactly four $1$'s strictly below the diagonal and $0$'s elsewhere.
-3
votes
2answers
120 views

How to convert a matrix to MATLAB format? [duplicate]

I want to convert the following 16x16 matrix containing the variable n and some integers into matlab programming language: ...
2
votes
3answers
64 views

construct matrix by applying derivatives to another matrix

Say you have a vector like the following ...
3
votes
0answers
74 views

Diagonalisation of equations for NDSolve

I have a linear matrix differential equation and I wish to speed up evaluation by diagonalising using eigenvectors. There is an example in Help for finite elements under "swinging beam" that is ...
4
votes
1answer
93 views

Speed up rendering of ContourPlot3D object

Please can you advise me how to speed up the rendering of the following two planes? When I click and drag to rotate the plot, its movement is quite jerky. Presumably it is working harder than I need ...
0
votes
1answer
122 views

Convert code from C++ to Mathematica [closed]

I need to know how to convert the following code in C++ to Mathematica. ...
5
votes
1answer
114 views

Evaluating only one column of a $m \times m$ matrix without evaluating the matrix itself

Suppose I have f[x_] := SparseArray[{someRules}, {m, m}]; g[x_] := MatrixPower[f[x], k]; Would it be possible to evaluate only the $n$-th column ($n\neq m$) of ...
1
vote
1answer
137 views

Plotting a list of Eigenvectors

For my Fractional Calculus course, I was asked to find a matrix that arbitrarily represents the second derivative. This eventually got me a tridiagonal matrix. I was letter asked to find the ...
3
votes
2answers
282 views

How do you create matrices using submatrix building blocks?

Here is a conundrum I am facing. I have $2$ matrix building blocks. In my problem, I associate integer $2$ with $3\times 3$ matrix $A$ with structure \begin{bmatrix} 0& a& 0\\ c& 0& ...
1
vote
0answers
72 views

Multiply a matrix by a vector [closed]

I have one 3x2 matrix of coordinates in the following form ...
0
votes
1answer
291 views

Syntax::sntxf: “…” cannot be followed by “…\MatrixForm” [closed]

I'm trying to create a $3\times 1$ matrix named Pauli but I really don't understand what's the problem of the following code? ...
3
votes
1answer
112 views

Interpolation of ListContourPlot3D, Volumetric data (cube file)

I know there are lots of information about this on stack exchange! Data interpolation and ListContourPlot InterpolationOrder for ContourPlot Unfortunately I was not able to find a proper way to ...