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

How to delete consecutive commas in an imported array in Mathematica?

I am importing an excel sheet into Mathematica. The result is a rectangular array. The array contains sequences of commas. Whenever a cell is empty in the Excel sheet consecutive commas appear in the ...
6
votes
2answers
11k views

Principal submatrix and Principal minor of a matrix

A submatrix of a matrix is obtained by deleting any collection of rows and/or columns. For example, from the following 3-by-4 matrix, we can construct a 2-by-3 submatrix by removing row 3 and column ...
0
votes
3answers
122 views

How to do two different kinds of binning for a given list of elements?

I have a long list consists of float numbers with some of them duplicated as shown below. I want to divide this list into bins; with equal bin width so that in each bin there might be one or more ...
10
votes
4answers
484 views

Scan through (partial) tuples

I have a list of list of positive integers $s = \{s_1, s_2, ..., s_k\}$, each list $s_i$ is possibly of different lengths, and I want to find out if there exists a $k$-tuple of the $s_i$ that sums ...
0
votes
1answer
23 views

Part Specification is longer than depth of object & Transposing Errors

In trying to recreate results from another question I had asked (here) Code is: ...
4
votes
2answers
62 views

From list to unique ID number AND back

If I have a series of list of the form $L_k=\{a_1, a_2,...a_n\}_k$ with $-4<a_i<4$ and $a_i\in\mathbb Z$, then I can make a unique ID number for $L_k$ using ...
1
vote
1answer
27 views

using a list of parameters in NSum

I am trying to make a function that uses NSum, that takes a list of parameters. But NSum doesn't appear to play nicely with lists. A minimum working example is: ...
8
votes
4answers
328 views

Nested Map. Iteration over a list

I am trying to add an element to a nested list. An example of the nested list is given below: cordxy = {{{1, 2}, {3, 4}, {5, 6}}, {{7, 8}, {9, 10}, {1, 2}}} I ...
14
votes
4answers
731 views

Generating Linear Extensions of a Partial Order

Given a set $S$ and a partial order $\prec$ over $S$, I'm looking for a way to "efficiently" generate a list of linear extensions of $\prec$. Suppose the partial order is given by a ...
1
vote
2answers
96 views

Converting Strings to Reals in a List

I am new to Mathematica and working with streamed data: ...
0
votes
0answers
34 views

Generation of nested list

Does anyone know a better way get the output generated by this code: Table[Table[{b-a,b},{b,7}]{a,7}]
0
votes
0answers
57 views

Plot a function with specific list of values and use manipulate

I have the following function: T[r_, theta_] := Cos[theta*\[Pi]/180]*r^2 which I would like to evaluate using predefined values of r from a function which I define ...
0
votes
1answer
42 views

Manipulating lists based on conditionals and 3D plotting the smooth surface that bounds a list of points

First of all I want to create a list of evenly spaceed points in a cubic region in $\mathbb{R}^3$. Then I want to keep the points in this list which satisfy a certain condition, i.e. a function that ...
6
votes
1answer
444 views

DeleteCases messing with my mind

I'm losing my mind. Please tell me my laptop is doing weird things and not me. Or do I need to get committed someplace? ...
0
votes
0answers
31 views

Problem with Table with some conditions [closed]

Please see my code, I have a problem with the Table function because F6, Phi7, and Gamma6 must be added in the calculation but in the result, I want the result ...
0
votes
0answers
25 views

Pure functions with derivatives and list elements [duplicate]

I have a list list = {x, y, z} and then the following line D[#, list[[2]]] & gives the output ...
0
votes
0answers
34 views

Confuse about joining and totaling sets with different lengths [closed]

Here is my code: ...
0
votes
1answer
81 views

How do I modify every nth element of a list?

I am working with the Mathematica S&P 500 data ...
2
votes
4answers
99 views

What is the easiest and efficient way to get positive or negative combinations of a list?

Consider the following simple case: list={1,2,2}; Subsets[{Splice[list],Splice[-list]},{1,Length@list}] This produces the following combinations: {{1}, {2}, {2}, {-...
0
votes
1answer
44 views

select partially matching filenames

I have two lists of files with slightly different naming conventions ...
0
votes
0answers
33 views

machine-size real number, compile [closed]

...
2
votes
0answers
82 views

Repeated calling of a ParametricNDSolve result in a faster way?

I recently learned of ParametricNDSolve and found that I need to compute it once and then call its result sol at different ...
2
votes
1answer
68 views

Formatting Imported Complex Arrays from Python (csv. files)

Just a short question, I am trying to import a complex array (matrix) from Python to Mathematica by first writing to a csv. file. When I Import the csv. array to Mathematica it is in a form (matrix ...
0
votes
1answer
55 views

SphericalPlot3D for a list

This question was asked before (here), but I couldn't get the answers to work. I have a list of values ...
0
votes
2answers
439 views

Mathematica: how to make Z transformation of data from CSV File

I have a discrete Signal in my CSV File and I want to transform it in Z. I import the data with Data=Import["T:/data.csv","CSV"] and I try to transform it <...
9
votes
6answers
436 views

How to judge whether two groups of sequences are equal in cycles?

There's a set of arrays that I want to remove repeated elements that are equal after rotation: ...
3
votes
2answers
78 views

Creating a list polygon's vertices from two lists of points

I would like to construct a list of polygons by using two different lists of points: ...
1
vote
1answer
40 views

table indices matching?

is there a way I can do something like, if h = Table[i, {i, 0, 5, 1}] so, I can access the 4th element of the h[[4]], so, what about going other way around that 3 ...
1
vote
0answers
41 views

Tables equates?

Is there any way if I can equate these two table, h = Table[i, {i, 0, 5, 1}] p = Table[j, {j, 0, 255, 51}] now how can I equate these two tables, let's say 0 of h ...
0
votes
1answer
73 views

Using MapThread and ReplaceAll together

I am trying to carry out some operations on the elements of dataset2, which is an 11 x 14 x 6 dimensional array: I have a function, ...
6
votes
1answer
122 views

Performance of select from a 3d list - Mathematica slower than Python

I am creating a random 3d data set in Matematica 12.1. Then I am selecting all points that are in a certain range of one axis. The same I am doing in Python (same computer, Python 3.8.5, numpy 1.19.2) ...
3
votes
1answer
89 views

How to generate isotropic tensors?

Consider a real tensor $\bf{T}$ upon $\mathop\otimes\limits_{n}(\mathbb{R}^3)$, with a definite order $n$, it could be isotropic, i.e., be invariant under the action of all elements in $SO(3)$(not $O(...
4
votes
3answers
97 views

Union of list with logical rules for combination

I have an list that I would like to reduce according to rules for combination. Examples of the input list (this will be a list of pairs and may be several hundred elements long) and the output I'm ...
3
votes
2answers
110 views

How to split a list based on pattern

I am trying to split a list based on pattern of some elements of the list. list = {a^(-1-x1),b^(-x2), (a+b)^(-x3), (1-a)^(-1+x4),(1-b)^(-1), (1+a b)} I want to ...
1
vote
0answers
66 views

How can I make 3 separate tables of parameters instead of only one table like this?

In the code below, how can I make 3 separate parameter tables for tup1, tup2, tup3 and plot ...
2
votes
2answers
127 views

Plot a list of functions with a corresponding list of ranges

I have 3 functions below and I want to plot them on the same graph with different range as follows. Plot f1 with x is in ...
2
votes
1answer
76 views

Multiply lists: element-wise but matrix-like in the last 2 levels

How can I do the following computation more efficiently? We have nested lists and want to multiply element-wise, where the 'element' is the deepest 2 levels treated like normal matrix multiplication. ...
0
votes
1answer
65 views

How to create a set (of matrices) which will be used as an finite group to minimize a function?

I'm new here so I'm a little lost. I need to minimize a function considering that the minimizing parameter belongs to a preestablished set. It all involves matrices.It's something like this: Where ...
6
votes
2answers
135 views

How to extract a column (or a row) of a matrix as another column vector/ column matrix (or a row vector), not as a list?

Suppose I have a matrix 'mat' as mat = Table[Subscript[m, i, j], {i, 5}, {j, 5}]; mat // MatrixForm I want to extract the first column (or any row) as ...
5
votes
2answers
129 views

Unexpected timing result of Total and Part performance of packed array

Define a = RandomReal[1., {2, 100, 100, 100}]; then Total[a, Infinity]; // RepeatedTiming {0.00183727, Null} and ...
0
votes
1answer
71 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 (...
4
votes
1answer
36 views

Select from list using a TogglerBar to specify one or several criteria

Simple version of my problem. Create a list of 50 integers. Create a TogglerBar to select one or more members of the list. Use Select to select sublists from the larger list. I can't figure out how to ...
1
vote
1answer
131 views

How to speed up by Compile?

I need to NDSolve a system many times by scanning some of its parameters and do some matrix calculation with the (discretized) solutions. The example is the ...
1
vote
1answer
49 views

understanding this timing result

I got two timings which I do not understand. ...
1
vote
1answer
383 views

Extracting unique values from array

I performed MorphologicalComponents on an image, and from there used SelectComponents to filter out my desired components. Is there a way to extract out the unique values from the entire array? i.e. ...
3
votes
1answer
104 views

Mathematica shorthand for mapping function over two lists simultaneously [closed]

I am still relatively new to Mathematica, so please bear with my question. I have the following statement that works perfectly well: ...
32
votes
6answers
2k views

Insert $+$, $-$, $\times$, $/$, $($, $)$ into $123456789$ to make it equal to $100$

Insert $+$, $-$, $\times$, $/$, $($, $)$ into $123456789$ to make it equal to $100$. Looks like a question for pupils, right? In fact, if the available math symbols are limited to addition ($+$), ...
0
votes
1answer
88 views

Moving average of events per minute

Suppose I have a list of times corresponding to event onset over the course of about an hour (in my case, skin conductance responses from electrodermal activity measurements). The amplitude of the ...
1
vote
2answers
607 views

3d Table to 2d table

I have generated a Table in 3 dimensions, for two variables x, y. ...
3
votes
2answers
216 views

Elegant way to rearrange year/date table into time series/values

I often have data in the form of YEAR JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC 1950 -1.022 -1.146 -1.289 -1.058 -1.419 -1.36 -1.334 -1.05 -0.578 -0.395 -1.151 -1.248 1951 ...

1
2 3 4 5
138