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
1 answer
197 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 ...
user avatar
7 votes
6 answers
317 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 ...
user avatar
  • 1,895
3 votes
3 answers
90 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 ...
user avatar
  • 319
5 votes
4 answers
321 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 ...
user avatar
  • 567
3 votes
0 answers
91 views

Filling the space with rectangles

The problem concerns filling the matrix m x n with rectangles. ...
user avatar
  • 969
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 ...
user avatar
  • 315
1 vote
1 answer
66 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', ...
user avatar
1 vote
0 answers
28 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: ...
user avatar
  • 1,287
5 votes
1 answer
88 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 ...
user avatar
2 votes
1 answer
103 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 ...
user avatar
  • 1,287
7 votes
6 answers
375 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 ...
user avatar
  • 937
3 votes
3 answers
138 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 ...
user avatar
  • 1,287
0 votes
1 answer
51 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$ ...
user avatar
  • 1,287
2 votes
1 answer
43 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 ...
user avatar
0 votes
0 answers
46 views

How to incorporate a data from list in Do loop?

...
user avatar
15 votes
11 answers
803 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 (...
user avatar
  • 15k
1 vote
0 answers
30 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: ...
user avatar
  • 1,252
0 votes
0 answers
32 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? ...
user avatar
5 votes
1 answer
398 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 ...
user avatar
  • 53
0 votes
0 answers
68 views

Sum of elements products equals to zero

I need to evaluate $\sum_i a_i b_i=0$, subject to the constraint $\sum_i a_i=1$. For the "a" summation being equal to 1, I generated a random list of 10 elements using ...
user avatar
  • 13
11 votes
1 answer
241 views

Association vs Pair - Creation performance, Selection performance

Suppose that we ...
user avatar
  • 2,451
4 votes
2 answers
338 views

Maps between finite sets

With SageMath, one can do FiniteSetMaps(["a", "b"], [3, 4, 5]) to get all maps from {a,b} to ...
user avatar
  • 315
4 votes
1 answer
68 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 : ...
user avatar
  • 2,451
3 votes
1 answer
78 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 ...
user avatar
  • 2,451
4 votes
2 answers
276 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?
user avatar
  • 43
0 votes
1 answer
60 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 ...
user avatar
4 votes
4 answers
201 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 ...
user avatar
  • 95
1 vote
0 answers
71 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 <...
user avatar
  • 2,451
1 vote
2 answers
174 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) ...
user avatar
  • 1,750
1 vote
3 answers
245 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 ...
user avatar
  • 45
3 votes
3 answers
199 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\}\}$$ ...
user avatar
4 votes
2 answers
140 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 ...
user avatar
0 votes
1 answer
48 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 $...
user avatar
  • 51
1 vote
1 answer
40 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 ...
user avatar
  • 81
13 votes
4 answers
590 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 ...
user avatar
  • 233
0 votes
0 answers
45 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 &...
user avatar
0 votes
1 answer
65 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 ...
user avatar
  • 2,451
2 votes
3 answers
54 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: ...
user avatar
  • 351
3 votes
2 answers
234 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 $...
user avatar
  • 912
2 votes
1 answer
57 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 ...
user avatar
  • 215
0 votes
0 answers
66 views

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

In Mathematica, there is a concept called packed array. ...
user avatar
  • 2,451
2 votes
3 answers
139 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 ...
user avatar
  • 361
5 votes
1 answer
118 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): ...
user avatar
  • 973
5 votes
2 answers
158 views

A Nothing for Associations

In the same way that Nothing disappears from Lists, is there a built-in that when it appears as the value in an association the ...
user avatar
  • 5,334
-1 votes
1 answer
52 views

A general term of this sequence [closed]

My question is about the set theory. I have c[0]={{1}} and i want to define c[n] as follows: ...
user avatar
2 votes
0 answers
39 views

Delete list item if message is thrown

I have a nested list with each element containing FindRoot like this: {FindRoot[a,b], FindRoot[c,d], FindRoot[e,f],...} ...
user avatar
1 vote
2 answers
74 views

FindFit; not a valid variable [closed]

I am trying to fit the function in model, however I get General::ivar: 5000.` is not a valid variable. this error. My code is that and ...
user avatar
  • 13
6 votes
5 answers
621 views

How to divide the second element of a list by a number

I have the following list of number: ...
user avatar
  • 181
0 votes
0 answers
45 views

From list shown below - highlight in BOLD the pair with the highest value

I have been trying for sometime to achieve the following:- Given the list - {{"E", 3}, {"D", 2}, {"S", 2}, {"M", 2}} a list of pairs which maybe 4 pairs - more ...
user avatar
2 votes
2 answers
238 views

Storing the data at the end of the For loop

I have a For loop ...
user avatar
  • 103

1
2 3 4 5
153