# Questions tagged [list-manipulation]

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

7,094 questions
Filter by
Sorted by
Tagged with
146 views

### change order element of a list in a particular order [closed]

I have this list : {0, 1, 2, 3, {0, 1}, {1, 0}, {1, 2}, {2, 1}, {2, 3}, {3, 2}, {0, 3}, {3, 0}} I would like to transform it with the following pattern : ...
171 views

### Diagonal matrix command in Mathematica

How to find the corresponding Mathematica commands for diagonal matrix operation in Matlab, e.g. AA=rand(3,3); Step 1.) finding the diagonal elements, and export ...
34 views

### A list of the exponents of the irreducible factors in a factored polynomial

I have a list of factored polynomials: {x^3, x^2 (1 + x), x (1 + x)^2, x (1 + x + x^2), (1 + x) (1 + x + x^2), 1 + x^2 + x^3, 1 + x + x^3, (1 + x)^3} I want a ...
53 views

### Best way to write a function that randomly takes definition from list of functions?

I want to define a function based on a random choice from a list of possible functions. For example, suppose the possible functions are {Sqrt,Log}. Then I want to ...
91 views

### Problem with fitting

If I have the following data (I have updated the data): ...
73 views

### What is “Flatten” doing to my elements?

Here's some of my code. x1 results in returning the position of a list in a {{{n1}},{{n2}}...}. Im trying to flatten it such that the list reads out as {n1,n2,n3....} some how it's adding elements. ...
85 views

### How to merge two DateObject list together?

I have two huge lists of flight data(one is around 7 million observations and another is around 1 million). The first one contains the city names, the departure time(accurate to the minute), and some ...
85 views

### Fitting an equation to data

If I have the followind data: data={{45, 2.93495}, {50, 2.94697}, {55, 1.9801}, {60,0.734437}, {65, -0.0128219}, {70, -0.695535}, {75,-1.35939}, {80,-1.47567}} ...
42 views

### alternative approaches to selecting elements from two vectors conditional on a third

The following will convey the idea: build a new vector based on an existing condition (boolean) vector. For simplicity, I'll build the conditioning vector (cond) in ...
59 views

The possible values to specify the Padding option of a PaddingLayer include a fixed value, ...
74 views

### Subtracting one list of lists from another

I have two lists of lists, like: ...
45 views

### How to merge lists if first element is the same in both lists

I want to join sublists if first element is shared. Input ...
42 views

### Monospacing variable-width fonts

In some (older) discussion forums, you are limited to a specific variable-width font that can't be changed. As a result, tables get messed up. Example: Bananas 588 Egg 111 Arctic Cucumber 810 How can ...
59 views

### Replace Square Brackets with Curly Brackets [closed]

I have a dataset like this (imported from .csv file): {[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15]} I want to replace all square brackets with curly brackets like ...
81 views

### Area bound (divided) by the y axis and a list data

I have an array of points in two dimensional plane, say A={{x1, y1}, {x2, y2},..., {x2000, y2000}}. The closed-loop formed by these points (by joining each point ...
76 views

### Command to make all items on the list functions dependent on a given set of variables

The title basically. A typical example is the co-ordinates of a particle, and I want to introduce time dependence to define it's trajectory. For example, if I have ...
48 views

### Problem using KarhunenLoeveDecomposition

I have a matrix called stochasticData.mat which size is 211302*50 and I need to perform the Karhunen-Loève decomposition on it to calculate the uncorrelated random variables. Note that stochasticData....
46 views

### Summing list elements for given index tuple

Is there a more compact way of summing certain elements of lists together when given a tuple of which elements to sum. For example if I am given the list of size 8: ...
43 views

### How to apply percent error to list of data [closed]

Say I have a list of data. data = {1,2,3,4,5} and those data values were measured with an instrument that has a listed 3% error. I can apply this per value with ...
68 views

### How to convert decimals to integers and joint them to a string for exporting

There's a list such as {0.1,2,0.15,5}. I want to know how to convert the decimal to integer( but begin with zero 0), and don't ...
101 views

### listing of vectors satisfying some special constraint

We have list = {{1, 1, 0}, {1, 0, 1}, {0, 1, 1}, {-1, 1, 0}, {1,-1, 0}, {-1, -1, 0}, {-1, 0, 1}, {1, 0, -1},{-1, 0, -1},{0, -1, 1},{0, 1, -1},{0, -1, -1}} ...
111 views

My code is ...
54 views

### How to convert Symbol to Number?

Question I have a variable x which is associated with the number 1 : x= 1 In the program, I faced with the data type problem ...
111 views

### Flatten outermost parenthesis

If I have the following data: ...
526 views

### Connecting the closest points on circles with a line

Suppose I have the function f[c_, z_] := z^2 + c and the following collection of circles in the plane. This is a simple example with only three circles, disjoint ...
73 views

### Correlation test for $x$ and $y$ values of a list

If I have the following data: ...
35 views

### Solve multiple equations with a parameter by means of Reduce

I have developed a program that solves an equation and give its solutions as outputs: ...
614 views

### Changing sign of elements of a list on even positions

I have a list of lists of equal sizes (odd or even), e.g. list={{1,-2,3,1,3,4},{3,5,6,-1,9,0},{1,-2,-4,-5,1,5},{1,-1,2,3,5,4},...} I would like to change signs of ...
462 views

### GroupBy sometimes deletes values

GroupBy[{1, 1, 1, 1, 1, 1}, # > RandomReal[{0, 2}] &] sometimes returns something like ...
52 views

### Take value from Root that comes from Reduce

When I try to solve a transcendental equation such as $e^{-2x}+e^{-3x}=x$ with Reduce I use the following: ...
46 views

### Separating list with nested sublists of different lengths

Consider the following list, with sublists of different lengths ...
36 views

### Difference on average of y-axis between data sets

How can I calculate in Mathematica the difference on average between the y-axis of two data sets such?: ...
35 views

### Smooth ListLinePlot with missing elements in list

Consider the following list: {{1,1},{2,2},{3,3},{4,4}} Plotting with ListLinePlot gives a smooth linear curve. How can the list ...
37 views

### Classifying sorted sublists using union

I'm trying to classify a list according to its sorted sublists. For example: ...
42 views

### Delete Duplicates by a distance test

Consider the following list which is of length 245: ...
73 views

### Null being added to every element in list list

I recently just started using mathematica, and I'm having some trouble figuring out what's wrong with this. When I run this, the output I get adds Null with every element. I have no idea what I'm ...
34 views

### ListPlot and ListLinePlot not working for imported files

I have a for loop which is supposed to generate a bunch of different values. I then exported these values in a file from which I am trying to extract and plot the data. I use ...
28 views

### Saving data from for loop to file and then read the data and plot graphs

I have a for loop which generates random matrices, then performs a few calculations to yield a bunch of different values. Essentially, something like so: ...
115 views

### check a sequence in Pi

I read that the string 36541622473 occurs in π(pi) at position 36541622473, counting from ...
685 views

### Replacing duplicates instead of deleting them

My code replaces each repeated element by "X". ...
121 views

### How to find the repeated elements in a vector

Is there a way to write a function where the input is a vector and the output is the elements in the vector that are repeated? I was trying to use something along the lines: ...
47 views

### Find fit for 3D data

Consider some dataset in the form {x,y,data[x,y]}: ...
202 views

### Is there a command which applies Position[] to each element in a list? [closed]

Given a list of elements, I want to produce something similar to Tally, but instead of counting how many times each element occurs in the list, I instead want a ...
137 views

### joining three lists to plot data with errors

I have three lists: x = {x1, x2, ...}, y = {y1, y2, ...}, yErr = {y1Err, y2Err, ...} that I want to join into the following format: ...
404 views

### Count number of balls in each bin, given a two-element sequence of balls and bins

If I have a list: {ball,ball,BINDIVIDER,ball,ball,ball,BINDIVIDER,BINDIVIDER,ball,BINDIVIDER,ball} The balls and bins can be in any permutation. Then, the ...
47 views

### Table/list: find the last real number element of each row to constitute a list

I have a list (Table), mostly composed of real numbers. The list also contains some non-real elements. The list is similar to the following (but much much larger): <...
32 views

### can i create a variable which is a list and the values given as placeholders?

I have a bit of a weird question: I have a program which I transformed from an old Mathcad Program written by someone else which is a hot mess. It uses a bunch of constants in lists as inputs in ...
37 views

### Replace points on a grid with numbers to maintain order

I am DMing a game of DnD and one of my players is really into fear effects, which is cool, but the effect of having monsters suffer from the "panicked" condition gets tedious to render via ...
Suppose we have two functions $z(x)=x^4+1$ and $y(x)=x^2+x+1$. Then how to plot $z$ vs $y$ (assuming in general that $z$ can not be written explicitly in terms of $y$)?