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

learn more… | top users | synonyms (5)

4
votes
2answers
2k views

For loop with steps other than 1

I would like to do a For loop with a jump 2*Pi instead of 1. For[j = 0, j <= nmax, (incr = 2 Pi), ...] Actually what I want to do is ...
4
votes
7answers
127 views

Distributing identifiers

I have a list that looks like this: {{"a",},{2010,0},{2011,10},{2012,27},{"b",},{2011,11},{2012,66},{"c",},{2010,19},{2011,20},{2012,}} I want to turn it into: ...
4
votes
5answers
246 views

Extracting Coefficients from a List of Sines

I want to extract the coefficients from the following list: list={16.2219 Sin[16.2219 t], 6.60924 Sin[6.60924 t], 13.927 Sin[ 13.927 t], 2.91309 Sin[2.91309 t]} ...
4
votes
8answers
468 views

How to sort my list?

For example I have two lists of such structure L1 = {{"Australia",a1}, {"USA",a2}, {"Norway",a3},...} L2 = {{"Russia",b1}, {"Norway",b2}, {"Japan",b3},...} I ...
4
votes
5answers
338 views

Pattern matching in nested lists

I'm sure this has been asked before, but I can't find the right combination of search keywords to find it. Apologies. I want to do a ReplaceAll on a list of lists, ...
4
votes
4answers
135 views

Expanding lists with split strings

I've got data of the type: list = {"Class","MW","10 - 11"} which I would like to split into a number of lists based on the number of characters in the second ...
4
votes
1answer
488 views

Change elements on different positions within a list

How can I change the elements of a list, say on positions {{1, 4}, {3, 1}, {2, 3}, {4, 4}} in one go? Take this list for example: ...
4
votes
3answers
107 views

How to get a line density from list density plot?

I have a list density plot from a list ls={{x1,y1,z1},{x2,y2,z2}}.... How can I extract the line density with a fix y, such that ...
4
votes
3answers
132 views

List of functions to list of parameters

I am working in a Dataset and I need to create a function for a ChartStyle option of a ...
4
votes
3answers
134 views

Inserting an indexed string into the 1st position of each pair in a list of pairs

How do I insert "Z" and then a number going from 1 to end (without space) in a list? I have the following list: Input: ...
4
votes
2answers
111 views

Sorting and keeping the main format of list numbers [duplicate]

I have a list with these elements: list={1/2 (1 + Sqrt[5]), 1, 1, 1/2 (1 - Sqrt[5]), 0}; I want to sort them with ...
4
votes
3answers
206 views

Replace elements in matrix to make it symmetric using automated procedure

I am generating a matrix using (mat2 = Array[Subscript[a, ##] &, {4, 4}]) // MatrixForm but would like to force Mathematica to make it symmetric. Thereby I ...
4
votes
5answers
146 views

New nested list from three lists

I have three lists. x = {a,b,c,d} y = {A,B,C} z = {{1,2,3},{4,5,6},{7,8,9},{10,11,12}} and I wish to construct the following list out of these three lists ...
4
votes
5answers
281 views

Summarize a list of pairs / (Using GatherBy and Tally?)

Given a list of (frencuently repeated and unsorted) pairs {Mode, SubMode} I want to form the list ...
4
votes
2answers
488 views

Finding positions of multiple elements in lists

I realise that Position[{2, 4, 8, 16, 32, 64}, 4] will return {{2}} I would like to do something like this: ...
4
votes
3answers
525 views

Preparing data for making an ErrorListPlot

I often have the following notebook in Mathematica, which I use to make a dataset and associated errors: ...
4
votes
3answers
386 views

Extracting Pareto elements from a list

How can I extract the Pareto elements from a list? For example, for that list: ...
4
votes
2answers
305 views

How can I use Max[] in a function that is passed a list not find the max of the list

For most functions in Mathematica, passing them a list will call the function on each element of the list. For example: ...
4
votes
2answers
279 views

Access pairs of vectors, rather than the matrices, in partitioned data structure at a levelspec

I have some old code to analyze correlation between 2 time series by looking at windows of different lengths shifting across the time series data. The code: gets 2 sets of time series data (in ...
4
votes
2answers
129 views

How can I get a list of the exponents of a polynomial? [closed]

I have a polynomial 1 + x^2 + x^4 + x^8 + x^9. I want a list of the exponents. {0,2,4,8,9}.
4
votes
3answers
144 views

Operations in nested lists

New to Mathematica, I have a nested list containing many lists(A) of 16 lists(B) of 3 integers(C). I wish to put in each (Aj, Bi, C2) the result of (Aj, Bi-1, C2)+(Aj, Bi, C1). I could do it with a ...
4
votes
4answers
316 views

Partition list into a given number of sub-lists

I'm having quite a hard time with the following. I would like to partition a list into a list of sub-lists, in such a way that the number n of sub-lists is fixed. ...
4
votes
3answers
233 views

Extracting columns from multidimensional list

Perhaps a very easy question but I posted this on the Wolfram Community and didn't get any answer.. Suppose I have data like: ...
4
votes
3answers
281 views

Conditional search along the columns of a matrix

I want to implement the following algorithm in Mathematica. Get element along main diagonal of a matrix. If the element along the main diagonal is positive, then return the positions of the elements ...
4
votes
3answers
711 views

Replace For-loop with functional code

I am very new to Mathematica. I have code written using for loops. I want to rewrite it using Map/Thread but I am not sure how ...
4
votes
3answers
165 views

Appending to sublists using “anchor” values

Say I have a set of lists that look like this: ...
4
votes
3answers
658 views

Separating positive and negative numbers into two arrays

$c$ is a vector with real numbers.I want to separate the positive ones and the negative ones into two vectors: $a$ and $b$. I have the following problem: When I do: ...
4
votes
2answers
304 views

Partition a set into $k$ non-empty subsets

The Stirling number of the second kind is the number of ways to partition a set of $n$ objects into $k$ non-empty subsets. In Mathematica, this is implemented as ...
4
votes
2answers
230 views

Simpler way to repeat an execution with 2D points?

q has the coordinates of quadrilateral. I can get the output below with brute-force but I want to find a simpler solution, perhaps something like f<-q[[1;;2]]. ...
4
votes
3answers
329 views

Counting elements skipped using Reap & Sow

I am using the following code to filter data based on the percentage change between points. ...
4
votes
1answer
171 views

Random Partitions

I want to write a function RandomPartition to partition a vector of length n into p partitions of varying (random) lengths. For example with ...
4
votes
3answers
146 views

How to get multiplication of the elements of a specific list/Matrix

Assume there is a list: List1={a,b,c,d}; Then I want to get these calculation: ...
4
votes
2answers
134 views

How can I use sequence in plotting domain?

I would like to plot a function but have a domain defined elsewhere as follows: xrange = Sequence[0, 2π]; Plot[Sin[x], {x, xrange}] However, this doesn't work ...
4
votes
2answers
187 views

How to convert a list of 3D points to a list of distances?

How do I apply a function (this case EuclideanDistance) between element i and i+1 on a list ...
4
votes
2answers
152 views

How can I insert an element every $n$th position in a list?

How can I insert an element every $n$ positions in a list? For example, inserting a zero as every 4th element to turn {1, 2, 3, 4, 5, 6, 7} into ...
4
votes
4answers
180 views

Using Cases to get elements in a list

I have the following list: ...
4
votes
3answers
288 views

Combining more than two lists by first column as index

Please bear with me. It might be easy but its been hard for me. I have say three lists: ...
4
votes
4answers
138 views

Subtracting list from list of same dimensions [duplicate]

This might seem like a basic operation I have already searched for similar answers but found none. I want to subtract the second elements of my list ct from the corresponding element in lt, and ...
4
votes
3answers
218 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$ ...
4
votes
4answers
268 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 ...
4
votes
2answers
978 views

How can I scale the y axis?

I have a file I import and read into a table of $2 \times n$. I can plot this data using the following code: ...
4
votes
2answers
162 views

Coordinates for multiple countries

I am trying to plot polygons for multiple countries, say "UnitedStates" and "Canada". US data is generated thus: ...
4
votes
2answers
924 views
4
votes
4answers
176 views

Robust function for manipulation of nested lists

I have a nested list of the form: ...
4
votes
2answers
244 views

Multiplying expressions within a list of pure functions

Let's say I have a list of pure functions that are nice algebraic expressions: say l = {(#1 - 1)&, (#1^2 + #1)&, (#1^3 - 1)&} What's an easy way to ...
4
votes
3answers
204 views

Renaming and indexing list of rules

I have a list of rules that represents a list of parameters to be applied to a circuit model (Wolfram SystemModeler model): ...
4
votes
2answers
362 views

Mathematica list element sort

I have a list, say, ...
4
votes
1answer
777 views

How do I treat elements in a list as variables inside a module?

I want to be able to assign values to a list element inside a module. For example if I have: ...
4
votes
3answers
145 views

Replace values in a list based on conditions

I have a list with negative and positive numbers list = {-1, -2, 1, 2} and I want to replace all negative values with 0 and all positive values with 1 ...
4
votes
2answers
148 views

Gridding in a Nested Matrix

We have a nested matrix as: nested={{he, {{e, f, g, h}, {s, 0, q, i}, {s, 0, q, j}}}, {ho, {{e, f, g, h}, {0, u, t, i}, {u, t, 0, j}}}} and with the line ...