Questions tagged [list-manipulation]

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

Filter by
Sorted by
Tagged with
1 vote
3 answers
68 views

Modifying list of lists to standardise lengths and field positions

Sorry, beginner here. I feel this should be simple but I'm struggling... I'm reading a set of race timing data from a web site and want to manipulate it into a list of lists that I can then export to ...
  • 185
2 votes
4 answers
258 views

Plot3D in Mathematica a function

How I plot the attached function $G(t,s)=s(t-1)$ for $0\leq s\leq t\leq1$ and $G(t,s)=t(s-1)$ for $0\leq t\leq s\leq1$(In Picature in Mathematica and How I change the color from yellow). I have tried ...
2 votes
1 answer
95 views

Convert tuples to numbers [closed]

The link Convert string of tuple of numbers to complex number is perhaps a bit too advanced for me to understand, but I wonder if there is some easy way to convert tuples to integers, e.g. ...
  • 1,273
4 votes
2 answers
167 views

How to create patterns for DeleteCases / Cases / Select: deleting elements of a list, from the condition of a negative element in a column

I've been trying to create a simple and "human readable" instruction for deleting elements from a list with an specific pattern. I have the following list and I would like to delete the ...
1 vote
1 answer
57 views

Adding timeline to ListAnimate

I want to add time in the ListAnimate so that after I exporting the video I can see the graph changes by time. For example I have a graph that is changes by time, ...
0 votes
1 answer
72 views

How to read 100 files and take the mean

...
1 vote
1 answer
213 views

Is it possible to separate two signals in Mathematica?

I have asignal and I would like to decompose it into two.. this is the datasetTot of both signals ListPlot[datasetTot, PlotStyle -> {Black, Black}] I know ...
9 votes
6 answers
455 views

Modify one list according to degeneracies of another

I have two lists, each with four elements, let's say listA = {0.3, 0.6, 0.6, 0.9} listB = {0.1, 0.2, 0.3, 0.4} Notice that the second and third element of ...
  • 1,967
3 votes
3 answers
134 views

How to make a table with three columns?

I am trying to make a table with three columns containing the values of p, q and W. I have written the following code which gives multiple columns. I have tried Flattening the table. but I could not ...
  • 664
5 votes
4 answers
373 views

Finding the periodicity (or wavelength) in approximately periodic data irregularly sampled

I have irregularly sampled data that looks as in the picture. Is there a function in Mathematica that allows me to find an approximate or average period or wavelength? I know beforehand that the data ...
  • 577
15 votes
11 answers
3k views

Fastest way to generate {{a,a},{a,b},{a,c},{b,b},{b,c},{c,c}} from {a,b,c}

What is the fastest way to generate {{a,a},{a,b},{a,c},{b,b},{b,c},{c,c}} from l={a,b,c}? I've tried ...
  • 335
1 vote
1 answer
88 views

Convert a polynomial to a vector [duplicate]

I am trying to transform a generated polynomial terms into a vector, I used the command 'MonomialList', ...
1 vote
0 answers
30 views

Efficient construction of a formal polynomial using list manipulations

I have a code which is probably extremely inefficient given my inexperience with Mathematica list manipulation. Take as input data: ...
  • 1,307
4 votes
4 answers
188 views

Parts of a Piecewise Matrix Function in NDSolve

First time posting. Reproducing the Problem I'm relatively new to Mathematica (using v.12.3), and working on a project. My problem can be reproduced with this. ...
6 votes
1 answer
98 views

Abs applied with explicit map not giving same result as built in threading

I was making a code change that required me to change some code that looked like Abs[list] to something that looked like ...
2 votes
1 answer
112 views

Introduce formal symbols indexed by natural numbers

I'm going to describe a toy example here which I'm hoping with some help, I can then soup up into the more complex application I have in mind. Suppose the input is a list of lists, and for now take ...
  • 1,307
7 votes
7 answers
425 views

'Mapping' the values of a list to variable

Suppose I have the variable expr1 = a[n] + b[n], and the list stencil={-1,0,1}. I want to make a function ...
  • 957
3 votes
3 answers
147 views

Deleting sublists where an element repeats beyond a repetition threshold

I am looking for some help constructing a function Part[M_,N_] which outputs the list of all integer partitions of positive integers up to $M$ such that in each ...
  • 1,307
0 votes
1 answer
62 views

Create list with integer partitions satisfying some conditions

I want to create a function PartSet[N_,M_] of two positive integer variables which outputs a list of all pairs of integer partitions for all integers up to $M$ ...
  • 1,307
2 votes
1 answer
48 views

How to swap multiple values in a large list? [closed]

I have a large list of data points ({{a,b},{c,d},{e,f}...}) that I need to swap the elements of for each point ({{b,a},{d,c},{f,e}....}). This is specifically for a curve-fit, so the data needs to ...
19 votes
12 answers
944 views

Partitioning a list based on a criterion for sublists

SeedRandom[1]; alist = RandomInteger[{1, 10}, 20] {2, 5, 1, 8, 1, 1, 9, 7, 1, 5, 2, 9, 6, 2, 2, 2, 4, 3, 2, 7} I would like to divide this list into sublists (...
  • 18.9k
2 votes
2 answers
87 views

Select rows with a specific element from a given table

Lets say I have 4 rows in alist = {{1, 1, 3, 3, 1, 6}, {1, 1, 3, 4, 1, 1, x}, {1, 2, 3, 3, 1, 6}, {1, 2, 3, 4, 1, 1, x}}; If I want to select and print out ...
  • 95
1 vote
0 answers
31 views

Placing plots around a circle with SectorChart

I need to position some graphs around a circle so that each occupies a sector. There're 18 graphs in total and the first five are shown below: ...
  • 1,262
0 votes
0 answers
35 views

Show list of points in NDSolve

When I was solving my ODE system with NDSolve, I obtain {x[t]->InterpolationFunction[{{1., 126.}},<>][t],y[t]->InterpolationFunction[{{1., 126.}},<>][t]} How can show a list point? ...
5 votes
1 answer
410 views

Why False && {False, False} does not preserve list structure?

I am on Mathematica 12.1.1.0 trying to perform a boolean operation over every element of a list, but preserving the list structure. When I run ...
  • 53
11 votes
1 answer
260 views

Association vs Pair - Creation performance, Selection performance

Suppose that we ...
  • 3,221
2 votes
1 answer
57 views

Wierd problem with Table and Evaluate

I have a very unpleasent problem with Mathematica, precisely with Table and/or Evaluate. After solving a parametric system with ParametricNDSolve, I'd like to collect the values of the solutions $f_3(...
5 votes
2 answers
404 views

Maps between finite sets

With SageMath, one can do FiniteSetMaps(["a", "b"], [3, 4, 5]) to get all maps from {a,b} to ...
  • 335
4 votes
1 answer
75 views

Replacement, PatternTest, Module related Question

Let's see how MMA handles following type of expression : Replace[L, {pattTest1->rhs1, pattTest2->rhs2, pattTest3->rhs3}, {1}] Specific example : ...
  • 3,221
3 votes
1 answer
81 views

Classifying elements, by the value of a fixed function, using Replace

Let L be a list of several lists. And the length of each list is less than 1000. You can create L by ...
  • 3,221
4 votes
2 answers
309 views

Sorting a list of "Low", "Medium", "High" into low, medium, high

I have a list with 10.000 entries containing "low", "medium" & "high" data. It is in random order. How can I sort that to low, medium high?
  • 43
1 vote
1 answer
68 views

Append data in for loop in table shape

I'm trying to append for every element of my for loop a complete table to my file myfile.dat, but everytime I run the loop I get it overwritten by the last cycle. ...
0 votes
1 answer
69 views

Create a Table with 3 different variables from 2 Lists and 1 Table

I am new to Mathematica. I learned how to join 2 lists to make (x,y) type of representation using Transpose@{X,Y}. Now my problem is that I have to make a table of 3 variables. I have one set of data ...
4 votes
4 answers
209 views

Modify list elements if last two entries are equal

Suppose I have a list as follows {{1, 1, 1, 1, 1, 3}, {1, 1, 3, 4, 1, 1}} and I want to check the last two coordinates are equal or not. If that is the case then I ...
  • 95
2 votes
0 answers
78 views

sometimes Select / sometimes Position is faster

As you see, For list L, L1(Select method) is slower than L2(Position method). But for list <...
  • 3,221
1 vote
2 answers
178 views

How to pick lists to satisfy a given form?

I have a list of the following struture: (my real list also has the same structure, just much longer not just 12) ...
  • 2,484
1 vote
3 answers
262 views

How to find the nearest string to another string in a mixed array

I am trying to find which string is nearest to another string in an array of numbers and strings. For example, say I have an array that is as follows ...
  • 45
3 votes
3 answers
208 views

Dropping list elements that are members of other lists [closed]

I have a set: $$A=\{\{1,2,3\},\{1,3,2\},\{2,1,3\},\{2,3,1\},\{3,1,2\},\{3,2,1\}\}$$ I want to drop elements found in sets B and C from A. $$B=\{\{1,3,2\},\{2,1,3\}\}$$ $$C=\{\{3,1,2\},\{3,2,1\}\}$$ ...
4 votes
2 answers
146 views

Selecting a row from an array by elements of a subset

Assume that A = Permutations[{1, 2, 3}] AND $$C=\{1,2\}$$ I want to apply this process $X=C\subset A$ The output is $$X=\{1,2,3\},\{2,1,3\}$$ How can the array ...
0 votes
1 answer
64 views

Find the parameter region where function returns negative value

I have a function $f(m,n)$ where m and n are positive integers. Suppose $f(m,n)$ is like a black box, I can get values of it when I enter values of m and n. I want to scan over a region for example $...
  • 51
1 vote
1 answer
70 views

List of ordered pairs from a dataset

I have a dataset with Keys Biz Unit, Rate, Average. Rate and Average are numerical values and I want to pull them from the dataset as a list of ordered pairs without the keys. I've tried various ...
  • 91
14 votes
4 answers
632 views

Monitoring Apply / @@@ over large lists

How to monitor and/or print partial progress of Apply, e.g. f @@@ list? I have found answers using Map (e.g. this nice trick using Echo, or this general trick), but ...
  • 243
0 votes
0 answers
53 views

Algorithm: Permutations & Signature

Theoretical side Simple example: If I have two sets $A_1=\{1,3\} ,A_2=\{2,3\}$ and Permutations[{1, 2, 3}]= $\left( \begin{array}{ccc} 1 & 2 & 3 \\ 1 &...
0 votes
1 answer
96 views

get positions satisfying multiple criteria

Given a list L. It is mathematically proven that there is no element in L matching 2 or more patterns in ...
  • 3,221
2 votes
3 answers
57 views

How to apply a logical operation to all expressions in a list [closed]

I have a list of expressions and I need to apply AND on all the items. Input: {xP == 1+x , yP == 3+y} Desired output: ...
  • 475
3 votes
2 answers
239 views

Fast element extraction [closed]

I have a list $A$ of $\sim$ $3.10^6$ complex numbers. I have another list $B$ of 15000 positions B={1,25,55,100000,...}. I want to extract the elements from list $...
  • 912
2 votes
1 answer
60 views

Displays a few lines on same graph

I've asked a similar question before, but this time I have a slightly more complicated issue. I have a list of lists, and I want to show a few of the lines in the list. The following code will plot ...
  • 245
0 votes
0 answers
68 views

Packed/Unpacked array - what object/like 0 or 1?/how to check/ [duplicate]

In Mathematica, there is a concept called packed array. ...
  • 3,221
2 votes
3 answers
142 views

Reducing list of pairs by summing repeating ones

I have a list of pairs $\{\{a_1,A_1\},\ldots\{a_n,A_n\}\}$. Suppose $A_i=A_j$ for some $i\neq j$. Then I would like to eliminate both $\{a_i,A_i\}$ and $\{a_j,A_j\}$ from this list, and instead of ...
  • 361
5 votes
1 answer
153 views

Factor out common terms from a list of terms

I was looking for an automated way to factor out common terms from a list. Example (assuming n<1): ...
  • 1,468