Questions tagged [list-manipulation]
Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.
6,770
questions
0
votes
0answers
6 views
Passing list into another list
Suppose I have a zero matrix Amat and a list of values ltest that contains the values of the matrix ...
0
votes
1answer
32 views
0
votes
2answers
71 views
4
votes
2answers
66 views
xyz SplitBy y then Drop y for ListLinePlot
I'd like a more efficient way of doing the following:
I have xyz data in the form of MyList for which I'd like to plot z as a function of x, split by y.
...
0
votes
2answers
62 views
Combining lists of a factors with multiplicity
I want to combine factorizations of integers (in the form output by FactorInteger, that is a list of factors with multiplicities) into the factorization of the ...
4
votes
2answers
65 views
How to extract subsets in a list based on the largest element in the subset?
For example, if i have a list as following:
...
0
votes
1answer
65 views
0
votes
1answer
38 views
3
votes
3answers
98 views
List manipulation: Find duplicates with respect to symmetry in sublists
I have the following list
...
2
votes
1answer
63 views
How can I calculate the Allan Variance of a list of Data?
I have a list with over 10.000 elements of data. Now I wanna calculate the Allan Variance of this Measurement. The Allan Variance is defined as following:
$$\sigma_y^2(\tau)=\frac1{2\tau^2}\langle(x_{...
0
votes
0answers
21 views
Parallelizing ToExpression on a list [closed]
I have a list {"a+b+c","asd+rhy+bgf","at+aw+aw"}.
What should I use to make ToExpression ...
3
votes
5answers
70 views
I want to Prepend the Row Number of the Matrix to all Elements within that row
I have a matrix of nested lists that looks like this:
...
4
votes
3answers
155 views
generating lists of integers with constraint
Suppose you have the list $a=(k_1,k_2,k_3, \dots, k_N)$ such that $k_{i}\; (i=1,\ldots, N)$ are non negative integers. How can you get all the lists that satisfy the constraint $\sum_{i=1}^{N} k_{i}=M$...
1
vote
1answer
39 views
11
votes
9answers
932 views
2
votes
1answer
201 views
2
votes
2answers
176 views
Delete a range of elements from a list [closed]
If I have a list of 100 integers, say {1,2...100}, and I wished to delete all elements that are greater than a random integer $n$, what command should I use for ...
5
votes
1answer
110 views
ReplacePart to substitute a row in a Matrix
I have a very large n x n matrix from which I want to take a row i from and substitute every element with 0. When I try the below command however, the ith row is not replaced by a list of n zeros but ...
3
votes
2answers
134 views
Replacing a random ith row and column from a matrix
Currently I am trying to delete a randomly-chosen $i^{th}$ row and column from a square $n \times n$ matrix $A$. So far I come up with the following code:
...
0
votes
0answers
58 views
Correct way to format numbers
I have defined the following function:
randvec[mag_]:= mag Normalize[Table[RandomReal[], {j, 1, 4}]]
I would like to format the numbers in the list so that they ...
0
votes
2answers
73 views
How to generate random vectors without repetition?
Say we have three elements, 0,1,2 and we want to generate 1000 random vectors of length 7 with these elements, i.e.
{2,1,0,0,0,0,2}
How can we do this without ...
2
votes
1answer
53 views
List of all possible unions of given sets
I'm trying to generate a list of all possible unions of some sets to generate a topological space from a given basic sets.
For ex: Given
{1}, {2}, {4}, {1,3}
I ...
1
vote
2answers
96 views
Can one make `Do'-Loops of arbitrary depth?
In the documentation for the Do[...] function, a loop of nesting up to any number of layers is supported. But to apply their function, one needs to know ahead of time how many layers of loops they're ...
-1
votes
0answers
45 views
Rotate and translate previously-plotted data
I have the following:
Show[data1, data2, data3,PlotRange -> {All, All}]
where data1, ...
1
vote
1answer
57 views
2
votes
1answer
58 views
Removing certain numbers from a list
If I have an list of numbers {1, 2, 4, 70, 11, 20, 56, 79}, is there a way to remove the list {2, 4, 56} from that list?
In my ...
0
votes
0answers
54 views
Appending to a list in a For-loop
I am new to Mathematica. Here is my problem:
Given the matrix
$\qquad M =
\begin{pmatrix}
2 & -1 \\
1 & 2
\end{pmatrix}$,
sum the overlap (inner-product) of it's eigenvectors
$\qquad \bigg\{\...
0
votes
1answer
79 views
Improve running speed of FullSimplify function
How can I make this code faster? The checking with FullSimplify takes a lot of time.
...
5
votes
4answers
139 views
How to drop/extract elements of a list which starts with Plus
I have the following list :
list={a^2, b^2, a^-1, a^2+b^2, (a+b+c)^-1, (a+b-c)^-2}
Do[Print[list[[i]]//FullForm],{i,1,Length[list]}]
I want to break this list into ...
0
votes
0answers
34 views
Iterating MovingMap with Nest
I am trying to create a background correction inspired by the PyMca strip background method. The data I'm trying to correct is a HPLC chromatogram in the form of a ...
3
votes
1answer
69 views
Remove errors from sublists after Excel import
I have a very long list such as:
https://pastebin.com/9vYDLsVp
At the end of each sublist for some reason I have {,-6}. How can I remove that from each sublist of ...
3
votes
1answer
103 views
Build Table of Edge Weight Sums
Is there a convenient way to build a table as generated by the code below where a 5th column (at the far right) could be added to the table that is the sum of the edge weights for the nodes in a given ...
0
votes
1answer
70 views
List Plot Error [closed]
I've produced this simulation of a superhetrodyne radio receiver. I'm pretty sure it's solid for the most part but I'm getting a list plot error.
ListPlot::lpn: {{{1.,0.},{2.,0.00104953},{3.,0....
0
votes
0answers
31 views
InterpolatingPolynomial: magnitude of coeffictions
I have a list of the type {{x,y},f} and want to get an InterpolatingPolynomial for that list. The x values all run between 1.3 and 2, the y values between 0 and 1. ...
3
votes
3answers
106 views
Alternative to Inner which allows level specification
Is it possible to restrict Inner to a certain level? According to the documentation, the expected behaviour for Inner is to ...
4
votes
2answers
55 views
Smart under-sampling of a large list of data points
I have dielectric functions of materials as lists of value pairs {{x1, y1}, {x2, y2}, ...} and unfortunately some of them are quite long, which is a bother in ...
6
votes
1answer
78 views
Partitioning a list to several depths
I an aware of the Partition command which partitions a list into sublists. I'm curious as to whether there is an efficient way to partition a list several times ...
4
votes
3answers
223 views
DeleteDuplicates and select which one to delete from a pair
In this case if two lists with the same total then one list is deleted.
Can I add one more condition to choose which one to be deleted, for example the deleted list between the two is the one where ...
4
votes
5answers
323 views
Randomly Choose from list but meet conditions
I have a list of integers from 0-99, but some of the integers have been randomly removed.
I want to pick a random integer that is still in the list, letās call it āaā but if a+1, a+2, and a+3 are not ...
8
votes
3answers
446 views
Improve running speed for DeleteDuplicates
How to make this faster? I want to remove elements that satisfy the condition below but it's way too slow.
...
2
votes
0answers
38 views
How to extract the same entries from two tables? [closed]
I have 30000 entries in two tables. Now, I want to extract those two entries which are the same. How can I do it? For example, I have two tables, say T1 and T2;
...
2
votes
2answers
193 views
Given a list of linear equations, what is a neat way to use solve on the equations of this list? [closed]
Suppose I have a list of equations, say {2x+b+3c=3, 7x+2b+c=1, x+b+9c=-2} what is a neat way to use Solve[] on that list? ...
3
votes
1answer
53 views
Removing specific entries from a list
I have the list
L=8;
indx = Range[-Ļ, Ļ, 2 Ļ/L]
(* {-Ļ, -((3 Ļ)/4), -(Ļ/2), -(Ļ/4), 0, Ļ/4, Ļ/2, (3 Ļ)/4, Ļ} *)
Now I want to delete specific elements of this list,...
1
vote
3answers
58 views
A conditional list generator with stored argument values
I have already made this and the question is really about "how to make this faster and more general (to save the 4 keypresses of D,o,[ and ] that have to be made per-parameter)"
The function:...
4
votes
4answers
80 views
Delete the sublist which can be others' subsets
given
lst = {{1, 5}, {2, 5}, {6, 8}, {6, 8, 9}}
I want to remove all the sublists which is any other's subset. For the above example, remove ...
1
vote
1answer
42 views
Subtracting elements of two sublists [closed]
I have two lists:
listA = {{h1, h2, h3}, {h4, h5, h6}, {h7, h8, h9}};
listB = {{g1, g2, g3}, {g4, g5, g6}};
and I need to subtract sublists to construct a list
<...
2
votes
1answer
56 views
Flatten for ListDensityPlot [closed]
How do I flatten a list of the form
{{{1, 2}, 3}, {{4, 5}, 6}, {{7, 8}, 9},...}
to put it in the form
...
9
votes
6answers
248 views
How to sort and extract a list containing products
I've some difficulties with lists containing products as elements, e.g. list = {A B A, A K B, A K R}, where A and B are from the same 'family', let's call it sector ...
0
votes
1answer
37 views
Define a function, that evaluates other function
I want to be able to write a Function (Operator), that gets 2 arguments. The first argument specifies the kind of "operation", the second the function on which to apply the operation. It ...
2
votes
2answers
135 views
Functional realisation of do-loop
I'm currently optimising my code and I'm using a lot of loops, so I was wondering if there is a smarter or faster way to do things like:
...