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

learn more… | top users | synonyms (4)

1
vote
4answers
153 views

Check if a scalar falls within the range given by sub-arrays of a matrix

I have a rank 3 matrix: r = {{{1, 10}, {19, 71}, {111, 159}}, {{1, 5}, {25, 63}, {118, 132}, {164, 185}}, {{1, 19}, {28, 49}, {157, 203}}}; and each of the ...
1
vote
4answers
260 views

Add Brackets to a string list

Hello stackexchange community! I have a stringlist with a value and his error for eg: {{"12","1"},{"13","2"}} Now i want to output this as something like this ...
1
vote
1answer
220 views

Map a function conditional on elements at multiple relative positions in a list

I figure this question has many solutions, and if an answer already exists it would be nice just to be referred to it. I need a function that 'maps' over my list and produces a list of equal length ...
1
vote
3answers
177 views

Listing elements starting from 0

The first element in a list v in mathematica is denoted by v[[1]] and subsequent ones are then ...
1
vote
3answers
198 views

How to manage list of list of rules?

Considering we have a list: str = "{1 -> {a -> aa, b -> bb}, 2 -> {2a -> \"{b -> bb}\"}}" Bringing this to expression gives: ...
1
vote
2answers
181 views

How do I disorder a list in Mathematica?

Given a list like this (the original list is much longer), how I can get a completely unordered list and save it in plain text? I change the file names (names at random), using a length of 5 digits, ...
1
vote
6answers
276 views

Converting two lists into a list of tuples [duplicate]

I wonder how I can turn the list $\{a_1,...,a_n\}$ into the new list $\{(a_1,1),...,(a_n,n)\}$, i.e $a_k \mapsto (a_k,k)$, how do I do that? I figured the function Tuples might work, but it just ...
1
vote
2answers
316 views

What quantity is this “length” called?

tmp = {x, y, z}^{1, 2, 3} Times @@ tmp Length[%] This gives a length of 3. But I was expecting 1. What is exactly this "length" of x*y^2*z^3 called? I would ...
1
vote
6answers
223 views

Deleting missing data with CountryData

I need to delete all of the missing entries after executing this line: ...
1
vote
2answers
74 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 ...
1
vote
2answers
154 views

How can I create a list containing the normalized element-by-element product of two given lists?

I have to calculate: How can I create such a sum? Do I have to set the factors of each term manually (one by one), like G1 = 1, H1 = 1, G2 2, H2 = ....? ...
1
vote
3answers
211 views

How to replace identical positions in two different lists

Assume that I have two lists like : list1={1,2,3,4,5}; list2={a,b,c,d,e}; I want to replace some elements from list1 into ...
1
vote
2answers
155 views

How can I select elements that are true

I have a list of lists. For example, list = {{0,1,0,1,true},{0,0,0,0,false},{0,1,1,1,true},{1,1,1,1,false},{2,2,2,2,false}} I'd like to find all lists that ...
1
vote
2answers
412 views

Mapping functions over multiple lists

I am not sure if this is a duplicate. Spent some time looking over list-manip questions. I’d like to know the Quickest Way to achieve the following Mapping of a function over multiple lists. ...
1
vote
1answer
147 views

Ways to access lists inside lists

I have gone through some reference material but I am not getting really good links that will help me grow understanding of ...
1
vote
2answers
223 views

Plotting array of vectors with conditions

Given data in the form list={{{1,2},{3,4},{5,6}},{{7,8},{9,10},{11,12}},...} a matrix where elements are 2-element vectors, what is a efficient way to plot this ...
1
vote
2answers
239 views

What ways are there to convert an Integer to a list of digits?

How can I convert an Integer to list of numbers? For example: 781049 ==> {7, 8, 1, 0, 4, 9} What are the possible ways of ...
1
vote
2answers
2k views

Finding a best fit curve and plotting it [closed]

I have a list as shown below: m01 = {{250, 0.083121}, {200, 0.0888446}, {150, 0.0992422}, {100, 0.121567}, {50, 0.186825}} I'm new to Mathematica, and would like ...
1
vote
3answers
254 views

Adding headers to sublists

I would like to transform the following list: ...
1
vote
2answers
298 views

Proper way to deal with lists and map

So, I wanted to do something that I assumed would be really simple. Given two lists, $A = \{a_1, a_2, ...\}, B = \{ ... \}$, I wanted to take a function $f(a, b)$ and generate a list with $\{ f(a_1, ...
1
vote
2answers
171 views

Using patterns in ReplaceAll to extract elements from tuples at arbitrary depths

Please consider the following: I need to extract from MyList all last parts of each 3-tuple. ...
1
vote
4answers
106 views

Difficulties with list manipulation

I have a list of five elements. For example, list1 = {a1, a2, a3, a4, a5}; I'm trying to get a list: ...
1
vote
2answers
47 views

Insert several rows and problem with Return

I wanted to write myself a function that makes it possible to Insert several rows into one list. ...
1
vote
3answers
135 views

List of prime powers

I have a list of not necessarily distinct prime powers. For example: {2,3,4,25,2,3}. I want to combine (multiply) the highest prime powers for each prime. In this case 25*3*4 = 300 since 25 is the ...
1
vote
1answer
77 views

Take sublist with fixed interval

For example: a = Range[20]; a = ArrayReshape[a, {4, 5}] I want to take elements from a with interval = 2 : ...
1
vote
2answers
70 views

Encoding variables

I'm trying to fit a Logistic Model using LogitModelFit in Mathematica. The data I'm using contain qualitative variables that I have to encode. I've searched in ...
1
vote
6answers
108 views

Make a new list by filtering unwanted rows

I have a list like this. ...
1
vote
4answers
166 views

Minimum and maximum values under conditions

Let's create some sample data ...
1
vote
3answers
182 views

Working with nested matrices

I have a matrix: A = {{a, b}, {c, d}} But each its element, itself, is another matrix too. ...
1
vote
3answers
99 views

Creating Graph with two or more values in second column

For a social network analysis I have two columns. The second column has one, two or more values. Something like this: ...
1
vote
3answers
190 views

How to update a list in a function in each iteration

There is a list with numbers 1 to 8 ( p1 ) and another list (j) which contains 4 numbers which shows different 4 positions of ...
1
vote
3answers
217 views

Generating a list of cubefree numbers

I am trying to generate a list of cubefree numbers (i.e. numbers when prime factorized contain no tripled factors) within a given range. Of DivisorSigma, ...
1
vote
1answer
330 views

How do I operate on a set of ordered pairs? [closed]

I have a calculation that will give me a lot of ordered pairs. For each such pair in a list, I want to square the elements and add them together. Here is an example of the kind of list I have ...
1
vote
2answers
260 views

How to arrange a list on a triangular pattern?

I've made a multiplication table with this: Then I removed the repeated permutations with: gg = Range[1, 10]; Subsets[gg, {2}] // TableForm Now, when the ...
1
vote
2answers
58 views

Combining data sets by adding y values [duplicate]

Suppose I have the following list of data {{1,2},{1,5},{6,1},{1,3},{2,1},{2,2},{2,3},{5,4},{5,2}} This is similar to my actual data in that each x value has ...
1
vote
3answers
81 views

ListPlot the results of FindMaximum [closed]

I want to plot a list of the form whose elements are of the form {value, {x -> value_x, y -> value_y}} The list generated by FindMaximum applied on ...
1
vote
5answers
153 views

How to split list to strings?

Considering a list: lst = {"1", "2", "3", "4", "5", "6"} How can I have two strings : str1 = "1, 2, 3" str2 = "4, 5, 6" ...
1
vote
2answers
176 views

Manipulating elements of a matrix, to loop or not ?

I have a grid of values generated from a MATLAB evaluation. Most of these elements are 0, some 0.5 and the remainder 1. I'd like to write a mathematica script which reads in the CSV and then, in every ...
1
vote
3answers
181 views

Defining functions when there are a lot of parameters

Suppose I have two lists of parameters: $\delta=\{\delta1, \delta2, …\}$ and $\gamma = \{\gamma1, \gamma2, …\}$. The question is: how can one use $\delta$ and $\gamma$ (the parameter vectors) within ...
1
vote
2answers
140 views

How to join several list interleaving with some fixed list between?

How to join several list putting some fixed list between? Like this MyJoin[{{a,b},{c,d},{e,f}},{x}] giving ...
1
vote
4answers
111 views

Converting format of list

I have a 2D array, data = {{0,1}, {1,2}, {2,3}}; I would like to convert it such that I get the x- and y-values separately, specifically ...
1
vote
3answers
171 views

Binning events with weights

I have two vectors, one containing sampled energies and the other one for each of these energies a weight: e(i) and w(i). I ...
1
vote
2answers
311 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 ...
1
vote
2answers
246 views

Sorting lists element by element [duplicate]

I have a problem regarding list sorting. Let's say I have a list of lists obtained using Subsets[], of the form ...
1
vote
2answers
595 views

How to find the position of non consecutive numbers?

Given a sorted table, how can I find the position of non consecutive numbers in the first column of the table? ...
1
vote
3answers
401 views

How to find intersection of multiple lists excluding empty ones?

I have lists like list1={1, 1, 2, 3}; list2={3, 1, 4}; list3={}; I want to find the intersection of all list. I tried the following way, but it's not working. ...
1
vote
2answers
432 views

Select rows from table by keys

I am looking for a way to iteratively select all sublists with the same ID (my 1st column, residual columns are AbsoluteTime entries). First, I obtained the list of ...
1
vote
3answers
165 views

How can parts of a list of lists be printed to the nb, at regular interval positions?

I have a large list of lists with the dimensions {441,21,21,3} of which I need to print the x,y,z data from every 21st part up to 441. How can I print the 21x21x3 piece of every 21st part of this ...
1
vote
1answer
76 views

Pattern matching list of elements with different heads

I have a function, which I want to accept only a list of kind of elements belonging to a group. The task comes down to finding an elegant pattern suitable for easy to read function prototype. As an ...