Tagged Questions
1
vote
1answer
62 views
1
vote
1answer
41 views
Partial row reduction of a matrix
I have an $m\times n$ matrix (presumably of full rank) with $m>n$, and I would like to row reduce it, but leave the last column unreduced; that is, I want to get output on the form
$\pmatrix{ 1 ...
13
votes
6answers
327 views
Matrix Rotation
If I have a 2 D matrix of any size say
$\left(
\begin{array}{ccc}
72 & 32 & 64 \\
18 & 8 & 16 \\
63 & 28 & 56 \\
\end{array}
\right)$
$\left(
\begin{array}{cc}
72 & ...
-1
votes
2answers
77 views
Convenient methods to sum select rows (or cols) of a matrix? [duplicate]
What are some convenient methods to sum selected rows or columns in a matrix? This question Summing along rows or columns of a matrix only addresses how to sun entire rows or columns ie, by level.
...
-7
votes
5answers
199 views
Translating MATLAB's cell2mat into Mathematica
How I can define a function in Mathematica such that it acts same as the cell2mat command in MATLAB?
Example (in MATLAB):
...
1
vote
2answers
85 views
How do I divide the columns of a matrix by the sum of its elements?
I am trying to create a transition matrix for a network. In order to do this, I need to sum down the column (the out degree), and then divide the column by the out degree in order to normalize it.
...
0
votes
1answer
78 views
Dynamic List Building and Exporting [closed]
My ultimate goal is to have a text file that contains the following information in the following format exported to a text file:
...
4
votes
1answer
116 views
Sorting a matrix alphanumerically
Somewhat related to Sort matrix by columns and rows without changing them, but more general.
I'd like to sort a square matrix (a 3 by 3 in my case, but surely the general solution will treat any), ...
1
vote
3answers
123 views
Convert coefficients of polynomials into a matrix
I have several sets of 5 polynomials of the form:
...
2
votes
1answer
38 views
Replace a specified portion of an array with elements from another smaller array
This may be a trivial question, but I have been at it for a couple of hours and I have not made much progress.
I have a 10 x 10 array (T) that I have used to generate an 8 x 8 array (Q). I want to ...
7
votes
3answers
126 views
Multiply a list of matrices by a list of vectors
How does one multiply a list of matrices by a list of vectors, elementwise? For example, multiplying
...
9
votes
2answers
203 views
Speed up 4D matrix/array generation
I have to fill a 4D array, whose entries are $\mathrm{sinc}\left[j(a-b)^2+j(c-d)^2-\phi\right]$ for a fixed value of $\phi$ (normally -15) and a fixed value of $j$ (normally about 0.00005). The way ...
0
votes
1answer
109 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:
...
3
votes
1answer
66 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
1answer
108 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
...
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
163 views
1
vote
1answer
120 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 ...
4
votes
6answers
185 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?
...
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
136 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 ...
2
votes
5answers
120 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 ...
3
votes
2answers
267 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 ...
12
votes
1answer
256 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 ...
9
votes
2answers
910 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 ...
1
vote
2answers
179 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
4answers
267 views
Prepend 0 to sublists
My question is similar to this one, but my goal is to prepend a single 0 the each sublist, not incrementally many 0's.
The file I'm working is a CSV containing around 50K sublists of length 35.
I've ...
10
votes
5answers
903 views
Best way to create symmetric matrices
From time to time I need to generate symmetric matrices with relatively expensive cost of element evaluation. Most frequently these are Gram matrices where elements are $L_2$ dot products. Here are ...
28
votes
2answers
595 views
Tiling a square
I wondered if there was a way to automate the process of finding a way to tile a tile into a square.
The idea is to represent the tile with a matrix of 0s for blank space and 1s for filled spaces ...
9
votes
2answers
215 views
How to extract and compute on the diagonal entities of a sparse matrix very fast?
As could be seen in the following code:
...
7
votes
3answers
324 views
Add lists with unequal lengths together to create a matrix
I'm trying to create a stacked bar chart using raw data coming from a MySQL server. The result coming back from one query is:
...
27
votes
6answers
1k views
How to visualize/edit a big matrix as a table?
Is it possible to visualize/edit a big matrix as a table ? I often end up exporting/copying big tables to Excel for seeing them, but I would prefer to stay in Mathematica and have a similar view as in ...
30
votes
6answers
4k views
Elegant operations on matrix rows and columns
Question
The Mathematica tutorial has a section 'Basic Matrix Operations', describing operations like transpose, inverse and determinant. These operations all work on entire matrices. I am missing a ...
29
votes
6answers
2k views
Does Mathematica have advanced indexing?
I have two $M \times K$ arrays $L, T$ where I would like to set all the elements in $L$ to zero whenever the corresponding element of $T$ is greater than 15. The ...
12
votes
4answers
638 views
What is the right way to rotate an array?
Suppose I have an array, not necessarily square:
a = $\left(
\begin{array}{ccc}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{array}
\right)$
I want to rotate it like one ...
4
votes
2answers
329 views
Why don't * and ^ work as I expected on matrices?
For example, this input...
{{1, 2}, {3, 4}}*{{1, 2}, {3, 4}}
produces this output...
{{1, 4}, {9, 16}}
and this input...
...
19
votes
5answers
992 views
What is the most efficient way to add rows and columns to a matrix?
Say I have a matrix m and a vector v.
...
