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

learn more… | top users | synonyms (3)

3
votes
2answers
214 views

Dealing with a huge dataset

I have two ingredients here: a big dataset contained in a list, with ~ 20M values. a function that takes as each element of the list as input and yields True or False I want to save somewhere the ...
0
votes
3answers
141 views

Trouble understanding a piece of code found on Wolfram Blog

I am trying to go through this Wolfram Blog example: http://blog.wolfram.com/2009/02/12/flag-analysis-with-mathematica/ on country flag analysis. I am having a problem understanding the following ...
3
votes
3answers
92 views

How to test if all the elements in a list are Integers? [closed]

Consider a list such as s={1,2,3,3,5,6,3} With IntegerQ[number] , you know if number is an ...
1
vote
2answers
64 views

Replacing a specific pattern of values at level 2 in a list

I've a list of lists, tl = {{True, False, m12}, {False, m22, m33}, {m32, False, True}} and each nested list has the same length, What is the proper way to ...
2
votes
3answers
106 views

Delete Missing data from coordinate sets

I have a list of pairs of coordinates, where some are missing. ...
2
votes
2answers
126 views

Permuting elements within a list

I have s = {2, 3, 5, 7, 1, 4, 6} (* always with diffente elements in {1,2....7}*) l = Length[s] n = 3 and n tells us that we ...
5
votes
3answers
222 views

Split list of states by run lengths and discontinuous changes in state

I was asked to look into writing some simulation code for a user, where the simulation output (x) would oscillate between three possible states: ...
2
votes
2answers
86 views

Importing Data and Devoting Their Names to Them

There are some files in a directory. I have used of SetDiroctory to access all of them. SetDirectory["C:\\Users\\SE7EN\\Desktop\\mathematica\\test"]; I can visit ...
1
vote
2answers
141 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: ...
0
votes
1answer
43 views

Resolving Error: Mathematica evaluation order on Lists

I have a table that is 27 x 27, each entry corresponds to an element from the periodic table. I use the replacement rules in element list to allow me to convert a list of elements into a list of ...
0
votes
1answer
145 views

How to load data into a Manipulate expression

I have data showing truncated octahedron geometry changing with time. How can I read those data into a Manipulate expression? To be specific, I want to manipulate ...
3
votes
2answers
176 views

make a list based on two other lists

I have two lists: list1={4,6} list2={1,2} and I now want a function f that produces f[list1_,list2_]:={1,1,1,1,2,2,2,2,2,2} ...
8
votes
4answers
274 views

Complement of multisets

Given lists $a$ and $b$, which represent multisets, how can I compute the complement $a\setminus b$? I'd like to construct a function xunion that returns the ...
2
votes
1answer
44 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 ...
1
vote
0answers
35 views
4
votes
3answers
374 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 ...
2
votes
2answers
89 views

select from a list based on digits

I wish to know how do I count the number of occurrences of numbers that end in digits d. e.g. Say I create a list of Divisors of 12! I now want to count those divisors that end in 12. Like 12 & ...
0
votes
0answers
77 views
8
votes
2answers
347 views

Aligning two lists

I have two lists, L1 and L2, each with a key and some data. Let us say the key is a person's name, a string, and the data follows. (To respond to rasher's query:) Let us also assume the lists are ...
0
votes
2answers
82 views

How do I perform the riffle function backward? [duplicate]

I know riffle will combine the lists {1,2,3} and {a,b,c} to be {1,a,2,b,3,c}. Is there a way to work backward and split the list {a,b,c,d,e,f} to be {a,c,e} and {b,d,f}?
0
votes
1answer
71 views

how to apply a function to a list of tables

I have several files, and I want to extract for each of them a table, and then select just numbers, and keep only rows with five elements. My code works fine during import ...
22
votes
3answers
478 views

Undocumented form for Extract

Prompted by a comments conversation here, here's an interesting (and often performance enhancing) use of Extract: ...
1
vote
2answers
132 views

position of element in a list using a function

How can I find in a list l the positions of all elements satisfying a boolean function f. For example, how can I pick in ...
3
votes
6answers
312 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 : ...
6
votes
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.
1
vote
2answers
140 views

Find equal elements on a list

Consider the following code to produce the sequence $x_1,\ldots,x_{n+1}$ where $x_i=11\cdots1$ ($i$ digits 1). Is there an easier way to do this? ...
1
vote
3answers
117 views

Working with nested matrices

I have a matrix: A = {{a, b}, {c, d}} But each its element, itself, is another matrix too. ...
2
votes
1answer
91 views
40
votes
6answers
3k 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 ...
3
votes
1answer
117 views

Sectional averages of a list

I am working in Mathematica. I have a table of 200 elements. I want to calculate the mean value for the first 20 elements, for the second 20 elements and so on, up to 200. I will get a table (matrix) ...
0
votes
1answer
54 views

Taking Mean for several elements of a list [duplicate]

i have the following question: Let us assume we have the following list: list={1.1,1.2,1.0,2.1,2.2,2,0,3.1,3.0,3.2} I need a function that always takes three ...
0
votes
2answers
145 views

How to pass a list as function argument?

I have the following function lFreqPhylo[a_, Q_, b_, p_] := Sum[Log[freqFunction[r[[p]][[i]], L[[p]][[i]], a, Q, b, {i, 1, nbranches[[p]]}]; The objects L, r ...
2
votes
1answer
173 views

Is there a better way to create my rotational-symmetric (180 degrees) rectangles?

I have created a simple way to create rotational-symmetric (180 degrees) rectangles, but my stuffit function bothers me. No matter what I tried, I couldn't get it ...
0
votes
1answer
40 views

Testing a certain function over multiple levels

I regularly want to test if a certain function, here foo, gives the expected result when mapping it over n - level - matrices. My naive approach is to write: ...
0
votes
1answer
60 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 ...
4
votes
1answer
136 views

On elegant use of Inner and Outer on tensors

I have a collection of 5-element vectors each of which corresponds to an {x,y} location from a (20 x 21) grid. Because of that I represent that data as a (5 x 20 x 21)-sized tensor called ...
0
votes
0answers
27 views

Unexpected results from Thread [duplicate]

I've run into an issue where threading two lists with a generic function, f: Thread[f[{{1,1}, {2, 2}, {3, 3}}, {4, 5, 6}]] ...
0
votes
1answer
83 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 ...
0
votes
1answer
66 views

Apply function to output of previous function

I am trying to write a function that takes 3 tuples. Each tuple contains two lists which are first divided. This results in 3 lists. Then I want to take the Mean of all the columns. I can do this ...
6
votes
4answers
597 views

How to apply a function to a list of tuples

trialList = {{0, 24.701}, {1, 24.69}, {2, 24.733}}; f[x_] := x + 1; I would like to apply the function f to only the second ...
0
votes
1answer
67 views

Help with DeleteCases [closed]

Trying to delete small elements from a list with copy = DeleteCases[copy, {y_} /; y <= 1500.0 ] but it does not work.
1
vote
1answer
73 views

Matrix and string variable

There are $100$ .dat data files which contain numerical parameters. ...
0
votes
1answer
53 views

Manipulating lists with constant values [duplicate]

let us assume we have some data in the following form. Table[data[[1,i,{1,2}]],{i,1,Length[data[[1]]]}] This would give all $x-y$ pairs of the first file. What I ...
1
vote
1answer
59 views

If statement and elements of an imported data

I import a data file: SetDirectory["C:\\Users\\SE7EN\\Desktop\\mathematica\\test"]; dd = Import["data.dat", "Table"] Out[2] = {{1}, {2}, {3}, {4}, {5}, {6}, {7}} ...
1
vote
2answers
102 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 ...
16
votes
3answers
3k views

K-means clustering

In MATLAB, there is a command kmeans() that divides an array into $k$ clusters and calculates the centroid of each cluster. Is there any command in Mathematica to ...
1
vote
1answer
72 views

How to find the maximum values and the place of the max value in the list? [duplicate]

I have given an example to find the maximum value and its place in the list. Is it possible to find the local maximum in the sub-list of this list means local maximum in the each row of the list and ...
3
votes
0answers
78 views

Why does Part behave like it transposes lists? [closed]

From the documentation of Part: Part[expr,i,j,...] is equivalent to expr[[i]][[j]]... ...
17
votes
4answers
292 views

Setting parts of a list

Suppose I have list a = Range[10] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} in which I want to set some elements to be a list ...
2
votes
2answers
120 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 ...