Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.

learn more… | top users | synonyms (3)

2
votes
3answers
295 views

Re-arranging / selecting of a data table very slow in For loop [duplicate]

My task is quite simple; I have a table of data like M = {{1,2}, {1,3}, {3,4}, {5,1}, {6,9}, {6,8}, {6,1}}; so the table is sorted with respect to the first ...
0
votes
0answers
33 views

Check if a (possibly nested) list is real [duplicate]

I have a very large matrix of numbers. I want to check if all its entries are real. At the moment I am using realQ = And @@ Thread[Flatten[Im @ #] == 0] & Is ...
9
votes
5answers
426 views

Take both of the diagonals through an element in a matrix

I have a matrix like this: Reverse@Array[List, {8, 8}] // MatrixForm I need a function that given an element of this matrix will return all the elements ...
1
vote
1answer
159 views

Splitting dates into groups in half year steps

list = DayRange[{1999, 1, 1}, {2014, 2, 6}] I want to split this list into sublists one and a half year long, moving a half year forward every time. That would ...
0
votes
3answers
145 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 ...
1
vote
2answers
84 views

Apply a function to each element of a list and sum it

I have a list {-1.8, 1.44, 0.2736, -1.72514, 1.17612} where each element stands for a value of x. e.g. $x1 = -1.8$, $x2 = 1.44$ and so on. How can I find the ...
2
votes
1answer
203 views

Finding the optimal teams ranking based on the table of match results

My original question was this: So my task is to score all the possible rankings of the 14 SEC football teams and find the best one, using who won in head-to-head games as the sole criterion ...
1
vote
3answers
439 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 ...
3
votes
1answer
116 views

How do I get the length of held list without evaluating the list?

I used Extract with Hold to retrieve a sublist containing expressions I didn't want evaluating, e.g. ...
1
vote
1answer
126 views

Extra brackets of Position command

Command Position always comes with two extra curly brackets {{}} when it's just one index for the location. I use [[1,1]] in front of my position commands. Is there ...
6
votes
2answers
265 views

choosing the fastest way of finding position

I have this list {1,7,8,10} for instance. and a second list which is always smaller or equal to the first one say {10,7}. How ...
1
vote
1answer
96 views

A list containing zero elements

I have a list containing zero and nonzero elements. How can I throw away zero elements and just keep non zero ones.
2
votes
1answer
844 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 ...
2
votes
1answer
99 views

Explore a nested list

This question is similar to Numbering nested list according with Depth (or Level) I have a list like ...
0
votes
1answer
68 views

How to use ImageMultiply[] over a list of strings?

I'm trying to do the following: ...
6
votes
4answers
266 views

Using an ellipse as a threshold for Nearest function

The Nearest function can receive as a threshold parameter a radius to look for elements inside that. From the documentation: ...
0
votes
0answers
36 views

Updating List with Do works but not with ParallelDo [duplicate]

I am trying to find 5 minimas for some function. I can obtain the results if I implement a simple Do function. I tried to speed it up by using ParallelDo and then my code returns spurious results. ...
2
votes
3answers
312 views

How to transpose unequal lists

As the titel says I want to transpose a matrix containing rows of unequal length, to be able to transport them to excel (in row form, there are too many datapoint to write them in a cell. In another ...
2
votes
2answers
562 views

Fast way to extract data from a list

I used data=Table[{i,f[i]},{i,1,n}] to produce a list, here n is greater than 2^20 = 1048576. The function f(N) runs in time ...
4
votes
1answer
135 views

Searching for closest entry in a table

I have a large table of triplets whose structure is: list=Table[{a,b, RandomReal[]}, {a,1,100}, {b,1,100}] I would like to search through the list by looking ...
1
vote
1answer
123 views

Need help scoring randomly generated SEC football rankings

So my task is to score all the possible rankings of the 14 SEC football teams and find the best one, using who won in head-to-head games as the sole criterion (so not factoring in strength of schedule ...
0
votes
1answer
146 views

Generate encoding from nested list

Taking reference of Huffman code algorithm, ...
3
votes
4answers
349 views

How to apply a function of several arguments to a list?

I have a list of triplets: list = {{1, 3, 5}, {4, 5, 1}, {4, 9, 2}} How can I apply a function f to the last element of each triplet when f the last and ...
4
votes
2answers
206 views

How to set up and minimize a large system of equations to resolve the individual components

I am trying to set up a system of 400*N equations to deconvolute spectral data for four different compounds. I monitored 400 different wavelengths in N solvents (3 solvents in this case). In order ...
3
votes
2answers
231 views

List manipulation after importing txt-file

I have some problems converting data which I imported from a txt-file into proper Mathematica expressions. After importing my data looks like ...
3
votes
1answer
104 views

Recursion when randomizing elements in a list

I want to randomize certain elements of a list; Since the code list = {a, b, c, d, e, f, g}; list[[{1, 3, 5}]] = RandomSample@list[[{1, 3, 5}]]; list works fine, ...
1
vote
0answers
238 views

Convolve two sets of (x,y) data sets

I have two sets of data in the form a={{.1,2},{.2,3},{.3,4},{.5,6}} b={{0,8},{.1,4},{.2,7},{.3,1},{.5,10},{.6,3}} Both data sets have even spacing, although ...
0
votes
0answers
92 views
8
votes
3answers
303 views

Deleting quasi-duplicates from large list efficiently

I have the need to remove "duplicates" from large (>10K members) lists, where a "duplicate" is either a verbatim duplication, or the element's second entry exists as a first entry for some "earlier" ...
2
votes
3answers
132 views

Plotting lists, exact color values

I read some descriptions of similar problems but I cannot make them work in my example, I don't know why. I have list of 3 dim values to plot: x, ...
2
votes
2answers
118 views

Merge two Matrices without Duplicates

I have two matrices, for example: data1 = {{"c1", "c2", "c3"}, {2, 5, 3}, {54, 2, 3}, {11, 2, 10}, {3, 5, 7}}; and ...
1
vote
0answers
99 views

New list generated from the sum of elements taken from two lists

I have been using mathematica for a while, but I have problem wrapping my head around list manipulation functions. I would appreciate any suggestions. Here is what I want to do. ListV is a list of ...
-1
votes
1answer
115 views

Plotting the results of a system of equations

I believe this is a question of more list manipulation than plotting, but I hope you could help me. I solve numerically a system of equations of 3 variables, take only real solutions where one of the ...
2
votes
3answers
156 views

Join matrix based on conditions

Given the following matrix: ...
3
votes
4answers
207 views

Finding the location of the last day of the month in a list of dates

My question differs from earlier questions about getting the eom dates from a list; I want to get the position of those dates so I can get the corresponding values from other lists. My problem seems ...
7
votes
5answers
312 views

Manipulating a sublist based on position

I have a huge list with huge sublists of the form list={{a,b,c,d},{e,f,g,h},{i,j,k,l}} I am looking for a way to manipulate these sublists based on the positions ...
1
vote
0answers
34 views

How do I define a tensor from another tensor with summations? [duplicate]

Let's say we have a rank 2 tensor $g_{ij}$. This is basically a list with a Depth of 2. Now I'd like to calculate another tensor ...
3
votes
5answers
402 views

Minimum in a nested list [duplicate]

I have a nested list of {x,y,z} and I want to find out the values of x and y where z is minimum. I can write a nested For loop and do it ...
4
votes
3answers
181 views

Non-descending Tuples

I want to get all the non-descending tuples of a list with given length, for example: f[{1,2,3,4},{3}] ...
7
votes
1answer
259 views

Visualize a tree structure using TreeGraph

I have a code that generates a tree of graphics objects. The structure can be visualized like this, with each Rule constituting a parent child relationship: ...
4
votes
1answer
226 views

replace items in a list with items in a another list

Suppose I have a list A={x1,x2,x3}, a list B={3,4,5}, and a function f[x]=x1+x2+x3. Is there ...
9
votes
2answers
450 views

Rearranging a List

I am trying to rearrange/sort a list i.e. {{1,2},{10,140},{43,10},{1,140},{43,2}} into ...
0
votes
0answers
44 views

Arithmetic operations on columns [duplicate]

I have imported a file, data.txt, then plotted columns 2 and 3 as function of column 1 using the commands below. ...
5
votes
2answers
720 views

How to optimally solve and generalize this Conway's Game of Life puzzle

I tried solving this using mma. I am aware of this command - Cellular automata. But i don't want to use that coz then there is no challenge. So below is how i did it and my question is can this be ...
0
votes
2answers
93 views

List of lengths of runs of elements

I have a list where a few distinct numbers occur, e.g. {41, 41, 41, 1009, 41, 41, 41, 41, 41, 41, 41, 1009, 41, 41, 41} I want to extract the information of how ...
1
vote
2answers
149 views

Generating list of coordinates in $\mathbb{Z}^n$ given by set of inequalities

I am trying to generate list of coordinates that forms a subset in the integer lattice $\mathbb{Z}^n$. This set is given by set of inequalities. Right now, I am using the following: ...
1
vote
2answers
155 views

Discretizing data using quantiles in Mathematica

I am trying to discretize a long array of real numbers into a uniformly distributed integer array. To do this I am identifying the quantile where each real value sits and writing it out to the output ...
9
votes
4answers
578 views

Find positions of items in a list based on neighbours

How can I select items from a list where the selection criterion depends on the neighbouring items? For example select all indices where a change has occurred with respect to the previous element in ...
0
votes
0answers
24 views

Create a (maybe nested) list of nminimize solutions in a loop [duplicate]

I'm a total newbie in mathematica, so need some help. I understand that my question is about basics, but i couldn't find the answer in docs, google and here. Here is what i'm trying to do. ...