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
0answers
57 views

How to get List element after `[[ ]]` operation [closed]

How to get the first and second element in every last column from every row? eg. {{7,8}, {3,3}} ...
6
votes
1answer
118 views

How to obtain all subsets of a list with repetition?

I'd like to generate all lists of length m containing all possible element combinations from a given list of length n with ...
1
vote
1answer
45 views

How to optimize time to obtain large data set? [duplicate]

I would like to generate a set of data of matrix of size 1000 x 1000 x 1000 in a region defined by 0 outside the sphere of radius r=100 centered in the coordinate (500, 500, 500), and number 1 inside ...
0
votes
0answers
43 views

Check if two elements exist in a list

I would like to know how i can determine if two elements in a list exist. For example the setup would look like this: ...
4
votes
2answers
146 views

Sort nested list by a fixed order

I have a nested list like this one: list={{{a,1},{b,3},{c,5}},{{b,1},{c,3},{a,5}},{{c,1},{b,3},{a,5}},{{a,1},{c,3},{b,5}}} Now I need to sort the list such that the ...
1
vote
1answer
54 views

How to create a simple transformation function on lists using short form of ReplaceAll?

I can easily do this with Map so the real goal of this exercise is to get a better grip on using transformation rules. Please help with this. The outputs should be ...
13
votes
4answers
428 views

Group points which on several straight lines

I have some points, they are distributed on three straight lines, how to group points on the same line? I have tried FindCurvePath, but I got the wrong result. I ...
5
votes
1answer
469 views

Generating a list of integers that sums to zero

Given a pair of integers n and k, I want to generate all lists of integers of length n, ...
1
vote
1answer
47 views

Interpolate function against time

I have two vectors called lammdaWind11 and timeWind11. They are of size 51*1. I have interpolted each one independently as ...
4
votes
3answers
231 views

Shift the value of the elements in a list

goodmornig, I have a list of numbers like this: ...
5
votes
1answer
94 views

Using Table to Assign Values for the Index

I would like to assign values for the two indexes at the same time. For example: Table[x + y, {x, {1, 2, 3}}, {y, {1, 2, 3}}] will give me an output of: ...
3
votes
2answers
96 views

How to reorder a 3d (m x n x n) array to extract an n**2 length list of sequences of m points

I have a 900x100x100 array of floats called 'data' which is essentially 900 frames of 100x100 pixels. I want to extract 10,000 sequences of 900 values each. These are essentially the time series of ...
0
votes
1answer
43 views

Finding the list where the minimum is

So I have the following lists: TolRin=0.2; TolRout=0.1; TolC={0.02, 0.05, 0.4}; TolL={0.02, 0.05, 0.3}; I want to find the minimum on this lists and I know that Min can do that https://reference....
0
votes
0answers
44 views

Split list based on a threshold

Problem I have to split a list into multiple lists whenever any element of the list is above a certain threshold. The last element of my list is always zero or less ...
12
votes
2answers
1k views

How can I use fast Fourier transform (FFT) to solve a PDE (heat equation)?

I'm trying to solve a one-dimensional heat equation (PDE) with the Fourier transform numerically, in the way it was done here. The equation: , is subject to the initial condition: , where U(x,t) is ...
3
votes
2answers
97 views

Subtract lists in a list of lists

I have experimental data where every run is stored in subsaves, e.g. Run 1 has subsaves run1.1, run1.2, run1.3, run1.4. and the data are cumulative. I import the data of a run using ...
3
votes
2answers
68 views

Argument of maximum value of a table in range

I have data = {{817, 501}, {818, 549}, {819, 562}, {820, 534}, {821, 534}, {822, 535}, {823, 516}}; How to find argument "822" for 535 (which is the ...
1
vote
1answer
51 views

Deleting elements of a list with a condition [closed]

I have a long list of number-pairs, like this {{a,b},{c,d},{e,f},...{y,z}}. I need to delete some elements if its 2nd number is less than a threshold ...
0
votes
0answers
47 views

Numerical minimization of function

So I have the following equation: 3 Sqrt[9.15753*10^-6 + 25.1556 TolC^2 + 25.1556 TolL^2]==1; Now TolC and TolL can take respectively the values of these lists: <...
0
votes
0answers
36 views

Flatten a pair of matrices within a list of matrices

I have a list of matrices, which I think is better to give an example using the code. ...
5
votes
3answers
188 views

How to locate a value from a list

I made a list with two values in each cell. ...
0
votes
1answer
48 views

Formatting list by applying `Re` and `Im` [closed]

I have a list of the form $$\{\{ a_1, b_1\}, \{a_2, b_2\}, \cdots, \{a_n, b_n\}\},$$ where $a_1\in\mathbb R$ and $a_2\in\mathbb C$. I want to change the list to $$\{\{ a_1, \mathrm{Re}(b_1), \mathrm{...
0
votes
1answer
41 views

Count number of entries based on date

I have the following sample data: ...
1
vote
2answers
89 views

How to find non-zero integers in a list containing zeros and times? [duplicate]

I have lists like {0, 1, 0, 3, 0, -t2, 0, -(1/t2), 0, 0, 0, 0} including zeros, non-zero integers, and times. I wonder how I get the position of all non-zero ...
2
votes
1answer
63 views

How to manipulate functions?

This is probably a simple question, I have matrix a , and I construct b from a by adding a variable to the first column. b is a function of variable d, and now I need to do mathematical calculation on ...
7
votes
1answer
200 views

How to set deeper patterns in arguments within function definitions. For example if an argument must be a list of 1 or more strings

Suppose I want to define a function whose argument must be a List of only Strings and List must have at least one member. I know how to require that the Head must be a List but how does one qualify ...
4
votes
2answers
112 views

Map a function to irregular matrix column major_order

Suppose I have an irregular matrix ...
1
vote
1answer
50 views

How i can add an element of one sublist to other?

I have list. st = {{1, 2, 3}, {}, {}} It is nessesary to add the first element of any sublist to start of other sublist. In a quick way. Example: from 1 to 2 ...
5
votes
3answers
269 views

Make the elements in the grid appear one by one

I need to make an animation like this, start with a table at first, then each element filled from left to right, top to bottom, instead of dynamically generating grid, the current code can only ...
1
vote
0answers
84 views

Extension of /@ operation

If I want to extend this useful operation /@ into a "matrix" version, say for example (#1*{Cos[#2], Sin[#2]}) &/@ ...
0
votes
1answer
58 views

Export data to excel [closed]

If I have the following data of x and y: data=https://pastebin.com/LRjLMfcr How can I export data to excel to have the data in columns of x and y for each data set contained in the same tab, rather ...
5
votes
1answer
562 views

What is the best way to flatten a nested list?

I have a list called matcoeffE which has dimensions {10, 9, 7, 2}. However, I want to build a matrix with dimensions ...
0
votes
0answers
29 views

Handling nested AmbiguityLists

I am trying to process the output of SemanticInterpretation[] with ambiguities intact (i.e. using AmbiguityFunction->All). Some queries result in multiple ambiguities - for example for "...
3
votes
2answers
158 views

How not to Simplify square roots

Given t1 = {1/7 (4 + Sqrt[37]), 1/15 (3 + 2 Sqrt[7]), 1/2 (5 + 3 Sqrt[2])} I do not want to simplify the square roots. I want to get ...
4
votes
1answer
97 views

Binary permutation list code in Mathematica

Given some natural number $N$, I am interested in the set of all binary permutations of length $N$ (with the intention of storing in lists depending on how many $1$'s appear in each permutation). My ...
0
votes
1answer
101 views

Select the surface points of a body on a cubic lattice

I have a conceptually simple problem. Given an arbitrary shaped body on a cubic lattice, I have to select the points corresponding to the surface. An arbitrary point may have up to 6 neighbors and one ...
1
vote
0answers
39 views

Sortable Grid-like control for large data sets?

I've been using a roll-your-own function for a while that's a wrapper around Grid which adds a couple things I always use, like headers, dynamic sorting, filtering, and clipping (only showing the ...
2
votes
1answer
49 views

Assessing conditions on list of solutions

I have a list of solutions from Solve[] in the form ...
0
votes
1answer
78 views

How to use AppendTo in do loop?

list = {1, E, (3/2)*E^2 + (3/8), (5/2) E^3 + (25/8)}; AppendTo[list, 2*E*list[[{x - 1}]] + (2*x - 3) (2*x - 4) (2*x - 5) (1/4)*list[[{x - 2}]]] Let x from 5 to 10, ...
0
votes
1answer
46 views

any way to store the values of the controls of a Manipulate so that one can reuse them in the future excutions

I’m using Manipulate[] to adjust several parameters, which will eventually generate some figures. After I get the desired view, I’d like to store the set of control parameters so that I can reuse them ...
0
votes
0answers
44 views

Finding minimum in a list of lists

Imagine I have the following list {{0, {2,3}}, {-1, {5,3}}, {2, {2,6}}, {5, {5,0}}, {0, {1,1}}, {-2, {10,2}}, {3, {4,2}}}; I want to pick the element in the list ...
3
votes
1answer
101 views

How to extract different curves from a mixed dataset?

Suppose I have a dataset: ...
1
vote
1answer
65 views

Concatenating matrices using headings

New to Mathematica. I want to create and combine K1, K2, and K3 (shown in the first picture below) into the 8x8 matrix shown in the second picture below and keep the heading as shown if possible: ...
5
votes
1answer
145 views

Conditional sorting of columns in a matrix

I have a matrix with ten columns, and I want to rearrange these columns with three conditions. Column 1+2n and 2+2n (0<=n=<4) always remain together and in the same order (1+2n before 2+2n). ...
0
votes
1answer
144 views

How to use every number between 2^50 and 2^100 without having to rewrite the code? [closed]

What I have currently written returns a numerical value and stores it in b100. p and q are random integers of size 2^50. I want to use the same code to calculate values where p and q ranges from 2^50 -...
0
votes
1answer
35 views

FoldList type evaluation for multivariable function

In the example code which follows I define a two variable conditional function h[_i, _v], one variable denotes the integer index i, and the other is an N-dimensional vector v (I denote dimension 'N' ...
4
votes
1answer
145 views

How to randomly shuffle multiple lists of the same length in the same order

If I have a list, I know that I can use the RandomSample function to randomly shuffle the list. However, if I have $n$ lists, each with the same number of elements, ...
2
votes
0answers
81 views

Building a Matrix as a piecewise-function of the indices without for loops [closed]

I'm very new to Mathematica and this site. I've read that building matrices with For loops is slow, and I have experienced this myself on the current project. I'm trying to wrap my head around ...
5
votes
2answers
133 views

Selective list deletions

I have a list: lis = {{a,b,c},{d},{e,f},{g},{h,i,j}} I would like to remove each element that consists of only one subelement from the list to get: ...
0
votes
2answers
60 views

How do you sort a list based on conditions? [closed]

If i have an list that ranges from 1 - 100. How can i sort elements from the list. For example i want elements that has greatest common divisor 1 with the number 24.