Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [list-manipulation]

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

1
vote
1answer
38 views

How do I divide an integral into parts and sum the total?

I have an exercise looking like this: Analyze the integral $4\int_{0}^{1} \sqrt{1-x^2}\ \tex$ numerically by ng the interval (2,1) into three equal parts, then summarize the integral parts. I just ...
6
votes
4answers
118 views

Sort with assumptions

I have a list which looks like this list = {0, Subscript[x,7], -Subscript[x,3]-Subscript[x,9], -Subscript[x,9]}; and all the $x_i$'s are positive semidefinite (i....
2
votes
3answers
59 views

Divide a list into two lists with equal sums

I have a list with L elements. I want to find an index within the list, that divides the list to two separate lists so the sum of elements in each of them are equal....
2
votes
2answers
43 views

Delete duplicates in tuples

I use the following code to create a list of input parameters: ...
-1
votes
0answers
36 views

`DistributionFitTest` for 2D data [on hold]

How can I make DistributionFitTest accept 2D data? According to the Documentation - it should be able to accept multivariate data, and the test distribution can be ...
1
vote
1answer
24 views

Selecting specific elements of a list

Suppose we have the following list: ...
-1
votes
1answer
57 views

Liquefying of Nitrogen & Oxygen Gaseous to Liquid Phase. Thermodynamics. How to plot solution? Solved

Process of Liquefying of air composed of 79% Nitrogen & 21% Oxygen from Gaseous to Liquid Phases as Follows: 1) When Temperature is higher than T>83 k they both are gas. 2) at T=83 k and less ...
3
votes
2answers
173 views

The multiplication of list of matrices

I need to multiply 3 lists of matrices (b.a.b) as the following code ...
1
vote
1answer
52 views

Attaching independent variable values to data for curve fitting

I have a data set of $10^4$ entries. I want to plot the last $2000$ data with the same argument at $x$ axis and fit a curve. That means the range of $x$ axis will be $8001$ to $10000$ incremented by $...
0
votes
1answer
36 views

AppendTo doesn't update when interacting with PopupMenu

I'm trying to ListPlot a list calculated by the Button called "Plot" with PopupMenu linked ...
5
votes
2answers
110 views

Counting certain elements in lists

I have the following data set: n1 = 1000; data1 = {#, {RandomInteger[3, 20]}} & /@ Range[n1]; Dimensions@data1 {1000, 2} I want to count how often ...
0
votes
1answer
39 views

Select elements from a list depending on condition

Assume I have: list = {{Mean[{}], 668}, {1, 2}, {Mean[{}], 2}, {7, 8}} and I want to select only pairs, where the first element is not equal to ...
2
votes
1answer
57 views

Changing the elements of the list based on subscripts

Say I have a list of lists: {{Subscript[a,1],Subscript[a,1]+Subscript[a,2],Subscript[a,-3]}, {Subscript[a,1],Subscript[a,-2],Subscript[a,-4]}} Now, in the ...
3
votes
1answer
113 views

Padding lists for accurate plotting

I have the following data which is in the form of irregular/non rectangular arrays list1 = {{1}, {2}, {3}, {4}, {5, 6, 7}, {8, 9, 10}, {11}, {12}} To transpose ...
0
votes
0answers
85 views

Transpose problems

it must be a table but the rows where there are ^ are breaking everything ...
3
votes
2answers
53 views

Interleaving position

How could I proceed to interleave the presented values to obtain the same result obtained by this code? ...
1
vote
2answers
38 views

Removing elements from a (nested) list that don't have the same y values as another list

I have two unequal-length lists of ordered pairs and I want to subtract the y-values one (the bigger one) from the other (the smaller one) if they have the same x value. Ideally, I should end up with ...
2
votes
2answers
51 views

Table counting divisors

I have a simple table that I can't quite make work. Columns are as follows A function returning 1 if x divides ...
0
votes
0answers
50 views

Different Outputs When Calculating Within a Table and Seperately [closed]

I have a matrix which looks like this: $$\begin{pmatrix} a & e & 0 & 0 \\ 1 & b & 1 & 0 \\ 0 & 1 & c & 1 \\ 0 & 0 & 1 & d \\ \end{pmatrix}$$ where $\{ ...
19
votes
4answers
534 views

Is it possible to avoid unpacking when merging Association?

For example, if we have assoc = AssociationThread[{1, 2, 3} -> RandomReal[1., {3, 10}]]; and ...
4
votes
2answers
123 views

Converting from “matrix” data into “coordinate” data

Say I have data which looks like data1 - this is "matrix" like data (is there a better descriptor?). The data looks like a matrix, and at each point in the matrix, ...
2
votes
1answer
54 views

How to force ListPlot to print the new curve while keeping the old one

I would like to create a graph using ListPlot which prints new dataset every time the button is evaluated (based on the value given in ...
5
votes
3answers
220 views

Averaging over columns while ignoring zero entries

I have: list = {{1, 3, 4, 5, 6, 0, 9}, {4, 0, 3, 5, 0, 2, 0}, {1, 0, 2, 2, 2, 4, 0}} I want to calculate the average but without considering the 0s. ...
5
votes
7answers
264 views

Generating a list with duplicate entries

How can I get a function that gives the following output? listX = {a, b, c, d} numberX = 3 myDuplicatesList[listX, numberX] {{a,a,a},{b,b,b},{c,c,c},{d,d,d}}
1
vote
1answer
32 views

Table of numbers and their divisors

I want to create a table of random numbers and their divisors. The random numbers are given by ...
3
votes
1answer
33 views

How to check format [closed]

I am having troubles with the following data: slavelist = ResourceData["New Orleans Slave Sales 1856-1861"] I want to select all slaves with: ...
4
votes
2answers
60 views

Selecting elements of a list based on frequency

Suppose I have a list as follow: l = {{"a", "b", "c"}, {"a", "b"}, {"a", "d", "b"}, {"a", "c", "e"}}; Now I am going to flatten it and apply ...
4
votes
2answers
148 views

Commonest[] function doesn't actually show commonest elements

I'm using Commonest function on a list with 500000 words to get the 10 most frequent elements. Then by using WordCloud, I found ...
13
votes
1answer
674 views

Starting index at zero

In order to start an index at zero, I found N. Abbasi is quite convenient. For instance, (Note that in the original code by Abbasi, one of under scores _ in Notation[] was missing.) However, with ...
5
votes
7answers
408 views

How to substitute values from a list into a function?

I was hoping to take pairs of numbers from a list and substitute them into a function. So if my list was list = {{1,2}, {3,4}, {5,6}} and my function was <...
1
vote
2answers
127 views

MapThread conflicting with DynamicModule

Cross-posted: https://community.wolfram.com/groups/-/m/t/1625808 Answer posted on Wolfram Community I'm creating an interactive UI which allows the user to import data from a spreadsheet, perform ...
1
vote
1answer
38 views

comparing lists of strings

I have two lists of strings like this: ...
7
votes
1answer
351 views

Avoiding unpacking an array when altering its dimension

I am trying to flatten a matrix from 3-dimensional to 2-dimensional one. The original one has dimension for example {10,120,120}: ...
1
vote
2answers
83 views

reducing matrix size by linear operations on rows and columns

Suppose that I have the following matrix: matrix = Table[i+j, {i, 5}, {j, 0, 4}]; which generates I like to write a ...
0
votes
1answer
47 views

Using elements of list to solve a differential equation

I have created a list as shown in picture. the digits inside f are values of a and q respectively. I want to solve the Mathieu equation.....
1
vote
1answer
40 views

Inconsistency in SortBy [duplicate]

I have a list of data, I tried to SortBy it in two equivalent way, but the result is different. The data variable is something ...
0
votes
0answers
35 views

Summing pairs of elements in a list [duplicate]

I have to write a function that returns a list of all different pairs of numbers which add up to 10. For example for {1,9,3,7,8} the function should return ...
5
votes
3answers
261 views

List of numbers giving a particular sum

For the list {1, 9, 3, 7, 8}, I want to find pairs whose sum is $10$. I would like the results shown as ...
1
vote
1answer
62 views

Testing if elements in a list are within a list of ranges

I am trying to check if a list of resistors can be used to achieve a set of equivalent resistances. (Reciprocal of the sum of the reciprocals of the individual resistors is the equivalent resistance) ...
5
votes
2answers
214 views

Manipulating a general length function

As a minimal example, define a function like s[1,2,3]; this is a function of three arguments in this case, but I'd like to apply this general idea to functions like ...
3
votes
2answers
74 views

Convert a list of lists into a list of rules

I have some trouble converting an imported list looking like this: {{a, b}, {c, d}, {e, f}} into a list of rules looking like this: ...
2
votes
0answers
87 views

Deciphering the combination of a padlock [closed]

I have a set of numbers from 0 to 9 numbers=Range[0,9,1] I want to determine the combination of three numbers between 0 and 9. There is a correct combination ...
4
votes
1answer
84 views

Replacement expressions

I have the following expressions: R[1, 1] R[2, 1] R[3, 1] R[4, 1] sum[FF[3, ak[1] - ak[2], 1], EE[2, ak[2] - ak[3], 0], EE[2, ak[3] - ak[4], 0]] By what ...
4
votes
2answers
190 views

Comparing two arrays of unequal length

I have two arrays, say array1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; array2 = {13, 4, 6, 20, 21}; I want to compare these two arrays by cycling ...
0
votes
1answer
45 views

Multiplying corresponding entries in lists [closed]

I have the following lists of probabilities and scores: ...
0
votes
2answers
48 views

Filter lists by discarding sublists that contain integers different from 0 or 1

Imagine I have a list of the type Lst = {{1,0,1,1},{4,0,1,1}, {1,1,0,0},{2,1,1,1},{0,0,0,1}} I want to select only those sublists that only contain elements 0 ...
0
votes
0answers
47 views

How to optimize the code [duplicate]

How can I write the following code using lesser number of characters? Table[Table[{y - x, y}, {y, 8}], {x, 8}] I tried using ...
0
votes
1answer
46 views

I need an alternative to AppendTo using Reap and Sow

c = Table[RandomVariate[BernoulliDistribution[1/2], 3], 3] d = Total[c, {2}] list = {}; For[k = 0, k <= Length[d], k++, If[d[[k]] == 2, AppendTo[list, c[[k]]]]] ...
3
votes
2answers
105 views

How to remove from the data the rows of with fixed number of elements? [closed]

Consider the data which has the form data = {{x1,y1,z1},{x2,y2,z2,t2},{x3,y4,z4,t4},{x5,y5,z5},...} How to remove the rows containing three elements from the ...
6
votes
2answers
147 views

Time-efficient matrix elements grouping and summing

I'm interested in finding the quickest way of grouping the elements of a large matrix in sub-groups of NxM elements and them summing them together. To be completely clear, I'm actually not interested ...