Tagged Questions

102 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 ...
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 ...
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 ...
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. ...
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 : ...
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$ ...
44 views

Collect the lists

I have a list of lists from which I pick out the positions of the number 1 and then print out these positions for each list. I am having some trouble collecting what I am printing into a list / matrix ...
152 views

Binarizing a matrix

I have an image with a few bright pixels with the remaining ones very dark. The difference is in orders of magnitude. I want to binarize this matrix (corresponding to the image) making all values ...
110 views

Speeding Up Replacing of Labels in Large Matrix?

I am Mathematica novice and am trying to find a fast way to replace labels in some rather large matrices (512x512 or 1024x1024) that have resulted from segmenting images with WatershedComponents or ...
53 views

deleteduplicates Delete elements of a list [duplicate]

I have a math problem about Mathematica, I am looking help from you. I hope that you could help me. The Math Problem: list= { {0,0,1},{1,0,0},{0,1,0} ,{1,2,3}}; ...
232 views

All possible pairs of two items

I have 4 different items {1, 2, 3, 4}. I want to obtain all possible pairs of two of the items. I have written: ...
I have a matrix that has a variable number of columns and rows (but it is always square). The matrix is: $$\Gamma = \begin{bmatrix} \Theta & 0 & 0 & 0 & T & 0 & R_j \\ ... 8answers 685 views Replace interior of matrix with zeros I have f.e. the following square matrix: ... 1answer 88 views references in a nested matrix I have a nested matrix n: ... 0answers 82 views How to sequentially select, from a large set of tuples (of matrices), those with a certain property I'm interested in finding a computationally efficient way for selecting all tuples of matrices which have a certain property. The property I'm interested in is that I want the column sum, of f[the ... 2answers 144 views Getting good-looking matrix form output from a matrix having both scalars and matrices as elements I have a nested matrix n: ... 2answers 100 views Comparison Operation for Nested Matrices I have a nested matrix n as bellow ... 6answers 402 views Insert all elements from one matrix into another I have two matrices A and B which are the same size. Each element of A is a list of numbers. Each element of B is just a number. How do I insert each element of B into the corresponding list ... 1answer 67 views Matrix operations performed with column-vectors We have 3 matrices: m1, m2 and b. We want to apply matrix operations (dot or sum) in a ... 1answer 113 views Check every list element for appearance I'm used to MATLAB so this might be a stupid question but Mathematica is freaking me out. I have a big matrix with the following format: ... 4answers 402 views Generating an Ulam spiral An Ulam Spiral is quite an interesting construction, revealing unexpected features in the distribution of primes. Here is a related topic with one answer by Pinguin Dirk, who has provided one ... 1answer 47 views Complement for a Matrix In a matrix, there are some non-zero elements same as: aA= Also, there is a list such as: list = {a, b, c, d, e, f, g, ii, jj, kk}; I want to access to ... 3answers 378 views Efficient matrix / array generation What is the most efficient way of generating the following matrix? \left( \begin{array}{ccccc} 1 & 0 & 1 & 0 & 1 & 0 & 1 & \dots\\ \frac{1}{2} & \frac{1}{2} & 0 ... 2answers 136 views Improving code for comparing and modifying nested matrices I have a matrix such as: ... 6answers 321 views How can I construct a distance table? I have a list of city names (of arbitrary length), f.e. c = {"BAL", "NYC", "LAS", "AUS"}; and the distances between them : ... 3answers 128 views Working with nested matrices I have a matrix: A = {{a, b}, {c, d}} But each its element, itself, is another matrix too. ... 1answer 65 views Swapping rows and columns in matrix [closed] If I have an array like the following \left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{array} \right) How can I swap the rows and columns, so it is ... 1answer 82 views Matrix and string variable There are 100 .dat data files which contain numerical parameters. ... 2answers 134 views Building adjacency matrix from set data I have two sets: games and players. Players pick their games. As such I will have data say g1={p1,p3,p5},g2={p2,p4},g3={p2,p3,p5}. My interest though is to build the connections among players because ... 1answer 91 views Select positive value from a vector I am wondering how to pick out the positive Omega value from soln, and make these positive values into a row vector. I know how ... 2answers 107 views How to drop the identical rows and columns of a matrix? I'm currently trying to find a way to eliminate from a square matrix of generic dimension the duplicate (up to sign) rows and columns, obtaining a smaller dimensional matrix. I searched around here ... 1answer 137 views Find positions where two matrices differ I have two matrices A and B of identical dimensions. What's the simplest (shortest) way to find the indices of differing ... 1answer 138 views Multiple swapping of rows and columns m={{a, b, c, p}, {d, e, f, x}, {g, h, k, z}, {u, v, w, y}}; I want to swap 1st and 2nd rows by 4th and 3rd rows respectively. And then, swap 1st and 2nd columns ... 1answer 133 views Plotting with ColorFunction -> GrayLevel - no black This is probably a fairly trivial question, yet I have been unable to find an answer - help would be much appreciated! :) I am trying to plot a 28 x 28 matrix (tabulated data given here), containing ... 3answers 211 views Finding a better way to define a matrix I first defined a 171x171 matrix containing only zeros and then replaced 18 specific rows with nonzero entries. The other 153 rows will be average of 2 of the existing 18 rows. Rows 2 ... 1answer 157 views How to combine matrix with array without cycles? I am new to Mathematica. And I'm sorry for my English. I have created a matrix (6 \times 4) and an array (1 \times 4). I want to get another matrix that will have the first element from the array ... 1answer 87 views Populating an array with outputs of a function [closed] I have searched, but didn't find much help on my issue. I have an optical physics problem that I'm working on .. ... 2answers 131 views Manipulating sparse array elements Suppose I have two sparse arrays ... 1answer 196 views Drop selection of columns from a ragged array I have an application where I need to drop some arbitrary list of columns from a ragged array (where of course the shortest array rows have at least all the specified columns). E.g., given a ragged ... 8answers 341 views Fast way to get positions of “boxed” array elements? Given a 2D array (arbitrary numeric / evaluates to numeric elements, simplified for examples, and can be arbitrary dimensions so long as the operation makes sense, I'm working with 2K X 2K in my ... 1answer 285 views How can you convert a matrix back into a list of lists? It is very simple in Mathematica to convert a list of lists into a matrix: all you need to do is apply the //MatrixForm function to it and voila. Is it possible ... 3answers 137 views Implementing nested subtotals Inserting a nested subtotal in a spreadsheet is a facility that Excel performs very well. But if a subset of this facility can be implemented in MMA for a table which needs it the hassle of its ... 3answers 366 views How to expand the size of the matrix automatically? I have a matrix in 2x2 a ={{x, y}, {z, u}} I want to expand this matrix 3x3 b ={{x, y, y}, {z, u, x}, {z, x, u}} 4x4 ... 1answer 581 views Contracting with Levi-Civita (totally antisymmetric) tensor I have an array v_{ijk} which is effectively a rank-3 tensor with dimensions 3\times3\times3, and I need to contract it with e^{ijk}, i.e. evaluate v_{ijk} e^{ijk} (see Einstein ... 3answers 143 views Join matrix based on conditions Given the following matrix: ... 3answers 273 views Question about Map and Total Suppose I have a list and I want to generate a new list, such that$$ NewList[index] = \sum_{index \neq j}^{NumOfElts} \frac {1}{ \lvert OldList[index]-OldList[j] \rvert ^2 } $$Can I do it using ... 1answer 65 views Produce a 1-dimensional list of all unique matrix elements We have some symbolic matrix m, e.g. m={{1, x, 4 x + y},{0, x y + 4x, 4x},{7 x, x, 4x + x y}} and we want to produce as output a list of all the unique elements ... 7answers 1k views How to select all elements above the main diagonal of matrix? How to select all elements above the main diagonal of matrix? I need to create a list of them. 2answers 113 views How to create automatically some matrices for symbolic manipulation? I want to create in an automatic way some matrices to do symbolic calculations with them. They look like these:$$ \left( \begin{array}{cccc} a & 0 & b & 0 \\ 0 & 1 & 0 & 0 ...
In a recent Mathematica project, $(n \times 0)$- and $(0 \times n)$-dimensional matrices have suddenly become a frustratingly common edge case for me. For instance, consider the following two ...