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

learn more… | top users | synonyms (3)

0
votes
2answers
43 views

Sorting non-numerical lists [closed]

The Sort function will by default sort from lowest to highest. In[1]:= Sort[{3, 1, 4}] Out[1]= {1, 3, 4} However, if the list ...
1
vote
0answers
79 views

Unexpected output from oddSublists

I have just bought Mathematica and I'm in the process of plowing through Shifrin's great book. On page 74 the function oddSublists doesn't give me the expected ...
0
votes
1answer
104 views

How to format the data in a table to have only numbers

This question is in continuation of my earlier query, how to store output of a function in a table for future use. I am able to store the output of my function in a table, however the table consists ...
0
votes
1answer
86 views

how to store output of a function in a table for future use [closed]

I am new to Mathematica and if this is a simple query - please excuse me for the same. I am trying to solve a equation which is a function of two variables. From the solution, I need to store the ...
2
votes
0answers
33 views

Adding Elements to a List of Lists [duplicate]

I'm trying to do the following: Given a function f[x,y], I want to turn the list {{x1,y1},{x2,y2},...,{xn,yn}} into ...
9
votes
8answers
311 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 ...
7
votes
2answers
239 views

Is there a function which instantly tells you whether an element is part of a list?

I have a very long list of numbers and I want to check whether there's a function (something that would look like PartOfQ[element,list]) that tells you immediately ...
1
vote
1answer
50 views

Make duplicate string then join two strings together in a table

I have two lists of data, dataA and dataB. ...
0
votes
0answers
27 views

Problem with slot in If statement [duplicate]

I am struggling with slots, In this case I have a function int which gives either true or false. When it gives true, I want ...
0
votes
1answer
50 views

Extracting second value of each sublist [duplicate]

How can one get the second value of every array inside the outside array? I have the following data data = {{10, 20}, {30, 40}, {50, 60}}; I want to extract ...
0
votes
1answer
49 views

Optimise CPU-intensive list combining function

I have a list of numbers list1 from which I want to create another list (list2) consisting of only those numbers that are equal ...
1
vote
3answers
102 views

Gather lists according to another list

I have a first list of pairs like this one: ...
0
votes
0answers
39 views

Generating the set of all three-dimensional binary arrays distinct under rotation and reflection?

How can I automatically generate all possible three-dimensional binary arrays of size $(x_1 \times x_2 \times x_3$) where each array is distinct from all others with respect to rotation and reflection ...
3
votes
1answer
153 views

Extracting function calls from an expression

I have an expression like this: expr = F[0, 1] + 2 F[0, 0] - 17*F[2, 0] and I want to transform it to a list consisting of all function calls with its arguments: ...
0
votes
1answer
28 views

How do I pull from a data list for parameter values in a system of ODEs and then solve and plot?

I have a parameter set list and I would like to solve a system of ODEs multiple times using each parameter set in the list. Then I would like each set of solutions to be graphed on the same plot. ...
-1
votes
2answers
75 views

Plotting solutions of differential equations with different parameters

I want to plot x[t], when i manipulate w from 0.1 to 1.5. Here is what I've attempted, which does not work as expected. ...
0
votes
1answer
55 views

Plot graphs in different colors

I am generating a set of plots and exploring how changing a parameter affects the plot shape. I want each plot to be a different color, but the color rule i'm applying seems to only work for the last ...
1
vote
1answer
105 views

GatherBy and two conditions

I have a list of 4 dim points, given by ...
1
vote
1answer
167 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 ...
2
votes
3answers
177 views

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

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
30 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 ...
8
votes
5answers
282 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
121 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
115 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
62 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
130 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
298 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
106 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
101 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
243 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
81 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.
1
vote
1answer
202 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
79 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
49 views

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

I'm trying to do the following: ...
5
votes
4answers
206 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
27 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
232 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
337 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
122 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
86 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
106 views

Generate encoding from nested list

Taking reference of Huffman code algorithm, ...
3
votes
4answers
304 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
158 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
215 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 ...
2
votes
1answer
80 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
102 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
67 views
8
votes
3answers
238 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
100 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
99 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 ...