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
0
votes
0answers
2 views

Unable to operate on the table imported from .mx file

I saved a table by exporting it to .mx file. Now, when I import it back, it gives me the desired output. So, to work with elements of the table, I first define the imported table as (res2 = Import["...
3
votes
6answers
103 views

Joining lists with same elements

Let's assume that we have the following three lists ...
7
votes
2answers
76 views

How to check whether a sublist exist in a huge database lists in a fast way?

I have a database for example datatest (Length[datatest]=10) : ...
1
vote
1answer
101 views

Combining 2 Files . 1 line to many lines

2 Files A and B. A has 2593 lines and B has 18900000. I would like to Take A[i] and associate(added to the same line) it with 720 lines of B. Then A[1+1] associate it with the next 720 lines in B. ...
0
votes
0answers
39 views

1D rotation of a list on reals about about a given value

I am seriously having a brain fart. Suppose you have a list of real numbers ranging from 1 to 4. ...
4
votes
2answers
81 views

Ordering a list of integers

I have a list of integers which I am trying to order in the following way: remove all zeros from the list sort in increasing order of absolute value put positive values before negative values I.e. ...
6
votes
2answers
100 views
+100

Create an animation to pause at the specified location

How can I pause play at the specified location when export a gif file or using Animate? I want it to run automatically, no need to interact with the mouse. Here is an example: ...
0
votes
0answers
31 views

Grassman and Clifford algebras as quotients of the tensor algebra

I've been working with tensors in Mathematica; it's great to have something like TensorProduct built-in with linearity and everything. Maybe you can take advantage of these structures to work with ...
4
votes
1answer
50 views

Dotting two vectors that are contained in a list

Is there a way to dot two vectors that are included in a list? Let's say I have two lists that contain a couple of vectors ...
3
votes
3answers
108 views

Splitting a list into two lists each containing a range of elements from the initial one

If I had a list of let's say 20 elements, how could I split it into two separate lists that contain every other 5 elements of the initial list? For example: ...
1
vote
1answer
41 views

Merging two lists as a twisted comb [on hold]

We have two separated lists as list1={{1,2},{3,5},{5,8},{18,3}}; list2={{1,1},{7,15},{10,1},{17,3}}; But we have to reach at ...
3
votes
2answers
164 views

Bug or undocumented behaviour in Intersection

I have two lists consisting of element pairs: a1 = Table[{i, i^2}, {i, 10}] // N; a2 = Table[{2 i, Sqrt[i]}, {i, 5}] // N; I want to pull out from both lists ...
1
vote
1answer
37 views

How can I consolidate mapping code between different levels of lists?

I have a list with the following structure: ...
7
votes
3answers
214 views

Find sublists in a list by contents, then union them

I want to find two sublists in a list by an element they contain, and then union them, keeping them in the list. I have this code that seems to do the job, but it seems rather clunky. Is there a ...
1
vote
2answers
65 views

Replacing duplicates in a list

I have a list that looks like: {{-5,0,-8,-3},{0,3,-3,0},{3,-4,0,-7},{-4,-1,-7,-4},{-1,4,-4,1},{4,-3,1,-6},{-3,0,-6,-3},{0,2,-3,-1},{2,5,-1,2},{5,-2,2,-5}} I ...
1
vote
1answer
24 views

Using Select and AllTrue to filter elements of a large nested list based on relations between elements of the smaller nested lists

I tried searching but all similar questions seemed to be based around one Boolean logical statement. I'm dealing with a nested list of pairs partitions of integers, such that the sum of the two ...
6
votes
2answers
138 views

Collect data points in a list into weekly groups?

Consider data of a format such as ...
14
votes
3answers
3k views

Flatten at a certain level

In an earlier question the brainteasing fourth syntax variant of Flatten was discussed. I see that with ...
8
votes
4answers
757 views

How best to join tables, which have different lengths on the same column values which exist in both tables?

I think my problem is pretty simple, and in SQL this would be trivial. I have two tables ...
5
votes
2answers
174 views

Show two plots together: a two dimensional curve tangent to the maxima of a three dimensional plot

I have a list containing 3 columns and 6552 rows which can be found here. The plot of data is shown below: We have a cross cut ...
8
votes
4answers
258 views

Select elements of a list by comparing it to another list

Suppose I have the following lists: ...
3
votes
1answer
76 views

How to use indices during Map?

I want to map a function on each element at the "deepest" level of a list. The list can have an arbitrary number of dimensions. The function needs the indices of the element to which it is being ...
11
votes
1answer
179 views

What is the best way to use errors in mathematica M12?

Since ErrorListPlot has been superseded by new functionality in ListPlot for Mathematica 12.0, what is the best way to handle ...
1
vote
0answers
28 views

Problems with the parametric Recurrence Table

I am trying to construct a minimization program where I have to minimize a function with respect to a matrix. This matrix enters into the optimization program in a convoluted manner together with data....
7
votes
4answers
388 views

How to obtain a subset (of a 2-d set of points with random coordinates) having monotonically increasing ordinates

If I start with a 2-d set of points: ...
0
votes
3answers
352 views

How to show decimal points on the axes frames in mathematica?

I have a set of data g1 and when plot using n1, i got the plot shown in figure below. I need to change the x-axis label from (1,2,3,4,5...) to (1.0,2.0,3.0,4.0,5.0) and y-axis label from (50000,...
21
votes
9answers
6k views

Map and Apply a function on a nested list

I have a list like this: {{1,2}, {4,2}, {6,4} ... } I want to replace every second number with a function of that number. For e.g. ...
7
votes
9answers
492 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 <...
4
votes
4answers
115 views

How do I pass a “list of lists” as the argument to a function of the form F[x,y]? [duplicate]

I have a function F[x,y] and a list of the form: {{a1,b1},{a2,b2},{a3,b3},{an,bn}} Basically, I want to pass the list ...
5
votes
4answers
396 views

List, map function based on a condition

I have the following list: ...
1
vote
1answer
115 views

Numerically convolve lists in mathematica

I have a function $$\chi(x) = \frac{a^2}{a^2 + \left(\frac{d^{2}}{x} + x\left( \frac{ab}{x^{2} - c^2} - 1 \right) \right)^{2}}$$ which I would like to convolve with the Fourier transform of the ...
12
votes
1answer
136 views

Using Select on Dataset with missing keys

I have a very large dataset with about a million entries with up to 75 keys each. Across the whole dataset about half of the keys are blank. In order to reduce filesize, I have used the following ...
5
votes
3answers
466 views

Arrange a list in ascending order by deleting list elements

I am new to mathematica and currently learning it by solving some basic problems. I am trying to arrange a list in ascending order using a detailed IF loop. For instance if we start out with $\{1,65,...
2
votes
1answer
35 views

Do not skip empty table entries while importing data from HTML string?

Consider importing the following table from an HTML string: ...
1
vote
2answers
47 views

extracting pairs in which y-component has a relative maximum value

I have a list of several pairs. You can find it here or create it manually. Applying ListPlot on the intended list results in the below plot: How do I extract ...
0
votes
1answer
71 views

Nonlinear fitting does not perform appropriately

I have a list as below one: mustbefitted={{0., 1.}, {4.4, 0.982211}, {8.9, 0.961575}, {13.3, 0.942571}, {17.8, 0.923857}, {22.2, 0.906203}, {25.1, 0.046994}}; I ...
10
votes
7answers
975 views

How to take the beginning and end parts of a list with simpler syntax?

So basically you have a table of some values, let's call it a: a=Table[n,{n,10}]; (*{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}*) And you ...
1
vote
1answer
24 views
7
votes
2answers
377 views

How can I iterate this process?

a = RandomVariate[UniformDistribution[{0, 1}]]; b = RandomVariate[UniformDistribution[{0, 1}]]; c = RandomVariate[UniformDistribution[{0, 1}]]; a + a b + a b c ...
1
vote
1answer
27 views

Creating a tensor of rank $k$ from elements of a list

Given a list containing $4^k$ elements, how do I create a "square" $\underbrace{4\times...\times4}_{k\text{-times}}$ tensor of rank $k$? Intuitively, I would opt for the ...
0
votes
1answer
37 views

Contour plot of data

I have two vectors (plain lists), say a,b, from which I generated a 2d table, say mat. It's not a direct expression like ...
7
votes
4answers
88 views

Take $ n^\text{th} $ sub-list with equal distances

I have been looking at Span, Take, etc. functions but I couldn't figure out how can I extract elements likes this ...
1
vote
2answers
75 views

How to sample numerically a function using a mesh-grid function in 3D?

I am working on a problem where I want to sample a scalar function f[x,y,z]. The problem is how to obtain a mesh-grid in 3D (A grid of points in x,y, and z). In order to study this function. Of ...
2
votes
2answers
57 views

Stack Two Lists of Depth=2 [duplicate]

My question is to combine a matrix of values with a matrix of 2D coordinates: Coor = {{{a, b}, {c, d}}, {{u, v}, {s, t}}}; Value = {{1, 2}, {3, 4}}; I want to ...
0
votes
1answer
51 views

How to plot this data smoothly

I have three lists (appropriately padded), giving me three curves, however the curves are not smooth/continuous and with gaps. I tried to make the grid finer, but still I can not get around this ...
17
votes
3answers
1k views

Performance of Select

I have a dataset of 3D coordinates with a length of about $ 4\times 10^6 $. From this volume I am sequentially selecting coordinates along one axis and manipulating this subset. My question: Can the ...
1
vote
0answers
92 views

Calculate the intersection points of a line and a parametrically defined 3D surface

Thanks to Henrik Schumacher for advice to simplify the sample code: I would be grateful for any pointers on the following issue. A line from an external point intersects the surface at 2 points (...
1
vote
3answers
45 views

How to making a repeting list out of tables?

I'm a little bit trouble with the below task, I'd like to make a repeting list out of a table. This is the starting point for the list And I like to make them into this form: How should I make this? ...
13
votes
2answers
338 views

Map vs. Table for index-specific operations on 2D arrays

Many experienced users on this site tend to use Map (and its variants, MapAt, MapIndexed, etc.) rather than Table. When applying the same operation to every element of an array, Map does seem more ...
8
votes
5answers
286 views

Return last number in sub-sequences in a list of integers

Given a list of integers like this: z = {113, 117, 118, 119, 120, 121, 475, 476, 529, 538, 542, 543, 544} I want a function that returns: ...