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
5answers
24 views

Build a new flat list from a mix of part items and part spans

I want to modify a list of table row by adding an extra column. For that I Map the data with a pure function that evluate the new column value from exisiting one ...
3
votes
2answers
34 views

Extract values from strings according to units

I have a lot of strings, which have simple nomenclature of number-unit associations and am looking to extract the number according to the units. For example: ...
4
votes
2answers
57 views
5
votes
2answers
168 views

How to insert a character between any several characters without knowing indexes?

There is a list of strings: {"x1x2", "x1", "x1x2x3", "x3", "x4", "x1x2x3x4"} The goal is to insert "&&" between every two elements in a list. I need to ...
5
votes
4answers
280 views

How to replace numbers by letters in a special way?

There are few sublists: lists = {{0,0,0}, {0,0,1}, {0,1,0}, {0,1,1}, {1,0,0}, {1,0,1}, {1,1,0}, {1,1,1}} The goal is to put A if the first element of a sublist ...
1
vote
1answer
39 views

Is pattern substitution the canonical way of deleting items by value from list?

This is a very basic question, but I searched through the official docs for list manipulation and on the site, and I wasn't able to find a specific function to delete item(s) by value from a list. I'...
10
votes
3answers
569 views

Merging 4 matrices to one matrix

I am struggling with the task to merge four matrices as presented below. Since the matrices A-D contain more than just four entries it would be too complex to do it by hand. Is there a simple or ...
6
votes
2answers
108 views

Destructuring a list containing two items to use it as arguments to a binary function

I'm experimenting with the Through function. I suspect there is a way to use that function to obtain both the mean and difference of two values. But this doesn't ...
2
votes
2answers
73 views

Replace elements of a list if the conditional is false

There is a list: {1, {a, b, c}, 1, {1, 2, 3, 4, 5, 6, 7, 8}, {A, B, D, Z}} It contains sublists of different elements and several $1$s. The goal is to replace ...
5
votes
3answers
215 views

Making one list from two lists by grouping them in a special way

I have two lists: list1 = {{{x1,x2},{x3,x4}}, {{x5,x6},{x7,x8}}}; list2 = {{{x9,x10},{x11,x12}}, {{x13,x14},{x15,x16}}} I need to join them to get one list: <...
6
votes
2answers
150 views

Build a matrix from the coordinates of its elements and complete it with zeros

Suppose that I have a data set data (input): ...
4
votes
3answers
118 views

How to implement an integration filter on arrays?

I have the discrete integration filters: $$y(n) = Ax(n) + By(n−p) , \text{$A$, $B$ real constants, $p$ positive integer}$$ EDIT: in the initial version of this question I focussed only on the case $...
0
votes
1answer
30 views

Drop doesn't work with Dynamic lists

So I have this code right here. ...
1
vote
1answer
61 views

Track the location of of dot from noisy image

https://imgur.com/a/SnTYESG (subtraction between the image) https://imgur.com/a/ZdOS5wf (orignal image) From the original image, since my CCD camera is bad, I cannot really see anything. However, ...
2
votes
2answers
42 views

How to separate the real part of elements in a list? [closed]

I have this list of complex numbers, and I like to just have the real parts. but this happens; ...
1
vote
2answers
62 views

Selecting and plotting the solution that meets certain conditions

I have this equation of order 6, which mean there will be 6 solution of a in term of v ...
12
votes
3answers
443 views

How to replace all elements of a list by a rule “element” -> “element_”

I have a list: {a, b, c, d, e, f, g, h, i, j} The goal is to get: {a_, b_, c_, d_, e_, f_, g_, h_, i_, j_} I can replace ...
6
votes
2answers
156 views

How to divide list according to the pattern?

There is a list of lists: {{0,0,0}, {0,0,1}, {0,1,0}, {0,1,1}, {1,0,0}, {1,0,1}, {1,1,0}, {1,1,1}} I need to regrup it's elements according to a pattern: "if the ...
3
votes
2answers
55 views

Copy Form of list

I have a list like this for exmple: {{{1,2},{3,4}},{{1,2}},{{1,2},{3,4},{5,6}}} So now i have to copy the form of the list with oen depth less so my result would be : {{0,0},{0},{0,0,0}} The first ...
1
vote
0answers
18 views

Replace duplicate values in a list with incrementing number [duplicate]

For an input list of numbers ie: {6, 4, 2, 4, 2, 4, 6} For the first value in the list I'd like to replace it with 1, and also all duplicates of the first value with 1. Then the next value 4 would ...
5
votes
2answers
242 views

How do I check if proportion of values in list are mostly positive?

I'd like to return a a boolean variable that tells me whether numbers in a list are mostly positive. For example: a = {3,2,3,4,-1,-2,-5,3} There are 5 ...
0
votes
0answers
50 views

How do i transform a Matrix into a List? [duplicate]

Like the title says i want to transform a Matrix into a list so i can use LinearSolve what's the way to do it? ...
0
votes
0answers
44 views

Using SortBy on a list of a list of a list

I have quite a typical physics problem at hand, I want the eigenvalues and -vectors of a Hamiltonian matrix. I have a parameter s, which I vary in 1000 steps and for each step I want my H matrix to be ...
6
votes
3answers
272 views

Selecting from a list of tuples

Given a list tuples Tuples[Range[10],2] I'd like to select the ones that match a certain criteria. Namely that for every pair ...
3
votes
1answer
113 views

Confusing Nest function behavior

Using V12. I don't understand this: Nest[sin, x, 3] gives sin[sin[sin[x]]] and ...
8
votes
2answers
283 views

Selecting Primes from list of list

I want to use Select or Pick for selecting primes in all sublists. list = {{2, 3, 4, 5, 7}, {8, 9, 11}, {16, 17, 18}} I can do it by ...
2
votes
2answers
209 views

Moving every element of a list to the left one place (RotateLeft) but making last element 0

I have many lists that I would like to RotateLeft, but i want the last element to be 0 (rather than the initial first element). My starting list is: ...
0
votes
2answers
34 views

Defining a function with variables that were previously introduced

I have coefficients in a list: allAs = {1,2,3,4,5} And another list that is created with the Table function, with an "x" in each element which I want to find ...
1
vote
1answer
90 views

Finding the phase difference between fundamental harmonics of two waveforms [closed]

I have two periodic non-sinusoidal waveforms $WV1$ and $WV2$ (See Figure). I want to extract the fundamental components of these two (i.e. $WV1_{F0}$ and $WV2_{F0}$) and find the peak amplitudes and ...
10
votes
0answers
67 views

Different timing with large array assignment

Consider the following example n = 10^8; AbsoluteTiming[ A = ConstantArray[1., n]; // anyFunc; A[[2 ;; ;; 2]] = -1.; ] {0.388108, Null} ...
7
votes
4answers
577 views

how to write a condition for all elements of a list

I have a list a={no,no,no,no}; now I can want to an If so that if all elements of the above list are "yes" it does something ...
1
vote
2answers
35 views

Find the position of a whole nested list if one of the values in that list contains an “Indeterminate” value

I'd like to find the position of a whole nested list if one of the values in that list contains an "Indeterminate" value. For example. ...
2
votes
1answer
30 views

Filtering data in one step rather than two

When generating a table, whose elements are of varying length, is it possible to delete an element from this list, dynamically, based on its length? For example, given a data set, that is divided up ...
1
vote
1answer
38 views

Count occurrences of list elements in an expression

I have a list of elements and a large expression in these elements. I would like to count the occurrences of each of the list elements in the expression. Say, the list is ...
1
vote
1answer
23 views

Multiple List Plots for Arbitrary Set of Data

I'm trying to write some automated data analysis code for my research group, but I've run into a snag with Mathematica which I just can't seem to iron out. We generate data of the form: ...
0
votes
2answers
45 views

Summations on Variables with subscripts

One of my equations uses a set of variables which ultimately for a set of certain values gives a list of 8 numbers: c=13.9506 (31 - k) following cc(sub k) = Round[Table[13.950621339931203...
7
votes
2answers
178 views

Sorting sequences independent of color

I have two lists $R$ and $B$ of numbers written in red and blue. I would like to join those two lists and reorder them in increasing order to get a visual feeling of how both sequences are distributed....
4
votes
3answers
376 views

How to turn two lists of unequal lengths into coordinates?

I have the following two lists; ...
2
votes
2answers
59 views

How can I concisely define a matrix-form partial derivative operator?

I have a vector $\boldsymbol{u}(x,y) = \begin{bmatrix} u_x(x,y) \\ u_y(x,y) \\ \end{bmatrix}.$ I would like to get $\boldsymbol{\sigma}(x,y) = \begin{bmatrix} \sigma_x \\ \sigma_y \\ \tau_{xy}...
1
vote
1answer
44 views

Why does a list of Iconize objects not work with Map

I am trying to understand how to Map a function onto a list of Iconize objects. Here is a simple example: listOfIconize = Table[ Iconize[Range[10 + i]], {i, 1, 3}] ...
5
votes
1answer
218 views

Pass arguments to the list of functions?

Suppose I have a list of functions: functions = {f, g, h, ...} And all of those functions are in form of f[x_ , y_]. For ...
2
votes
2answers
77 views

Question about loop control issue

I am new to programming and try to calculate the values of A[t] for $t$ from 0 to 0.5 in steps of 0.025 as follows but it does not work; ...
2
votes
1answer
46 views

Extended Euclidean Algorithm

I am trying to program the Extended Euclidean Algorithm. Earlier I made some progress past simply generating garbage data. I am supposed to yield two constants s & t that would help compute the ...
3
votes
1answer
73 views

NextKSizePartition, or how to partition a set into subsets of size $k$ but incrementally

This question might seem very much like the linked one below but it differs in a very special way; Mr.Wizard suggested I start a new post: Partition a set into subsets of size $k$ What I want is to ...
1
vote
1answer
40 views

Converting coordinates in $\mathbb{R}^2$ to a point in $\mathbb{C}$ (and back again) [closed]

I have a list of control points for a BezierFunction. I want to apply a function taking input a complex number to these points and then plot the BezierFunction of the resulting points. I'm looking for ...
4
votes
3answers
411 views

Delete a whole nested list if one of the values in that list contains an “Indeterminate” value

I'd like to delete a whole nested list if one of the values in that list contains an "Indeterminate" value. The link below provides a solution to delete individual "Indeterminate" values: Delete ...
5
votes
1answer
53 views

Delete rows by testing multiple columns againts a range of test values

If I have a matrix or table of data, ...
1
vote
0answers
80 views

Measuring Degree Correlations of Networks

I'm trying to write a program that will measure the degree correlation of the network. The theory is here (page 8). I've written something like this up to now: ...
1
vote
0answers
38 views

How to compute the multiplicative order of an element in a finite field

I want to find the multiplicative order of say the element {0,1,0} in GF[8]. I made a list: b = Map[GF[8][#] &, Tuples[{0, 1}, 3]] I tried: NestWhileList[b[[3]]*# &, b[[3]], # != b[[5]] &...
1
vote
1answer
44 views

How to Make Table Headings [duplicate]

In the code below, how can I add (left to right) column headings "n", "pp","aa"? There is also a shift in the alignment across the generated rows. ...