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
4
votes
3answers
142 views

Optimising the Selection of MaxValue in Association

Suppose I have the following Association: ...
8
votes
3answers
250 views

Create Array from list of indices/values

Is there is a performat way to convert something like {{0,0},a},{{0,1},c},{{1,0},d},{{1,1},e} into {{a,b},{c,d}} The ...
5
votes
3answers
103 views

Coverting list of string into integers and reshaping the original list

I have the following list which I am importing from Pyhton - thus the format: l = {{"a", "[1,2,3,4,5]"}, {"b", "[6,7,8,9,10]"}} I wonder how can I covert this ...
6
votes
4answers
300 views

How to delete certain lists from a nested list?

I have a nested list as the following example (want to remove lists with same or incremented elements such as {1,2,3,4,5}, {2,2,2,2,2}, {1,1,1,1,1}): ...
5
votes
3answers
333 views

Mathematica function equivalent to Matlab's residue function (partial fraction expansion)

I am looking for a Mathematica function equivalent to Matlab's residue function. If there is no Mathematica equivalent, I would like to write a function that given the coefficients of two polynomials ...
0
votes
0answers
48 views

How can I Joint two lists? [on hold]

I have two lists: list1 = {a, b} and list2 = {c, d}. I want to joint two lists into a list ...
0
votes
0answers
37 views

Interpolation data in two variables

I try to interpolating the data Data = RandomReal[{0, 1}, {7, 7}] using the a[k_, j_] := Data[[k]][[j]] for example ...
0
votes
1answer
40 views

unexpected Transpose::tperm error [on hold]

I am trying to use Transpose on the two lists of same length: Mathematica code is ...
5
votes
3answers
125 views

Pure functions applied to a two dimensional list

Lets say I have a two dimensional list: list = {{a, b, c}, {aa, bb, cc}, {x, y, z}, {xx, yy, zz}}; and two pure functions: ...
8
votes
4answers
315 views

Optimising Table wrapping over a Select

Suppose we have the following lists: ...
0
votes
0answers
67 views

Efficient Mathematica Code for List Problem

Say we are given $f(m,n)=m \pm 2n + (-1)^n$ where $m>0, n>0$, $m$ as well as $n$ are integers. The problem is to generate a list of all the integers that will not be found in the list of values ...
5
votes
2answers
368 views

Turning arguments into exponents

I'd like to replace every instance of L[stuff], e.g., L[-1,-2,-2] in an expression with ...
1
vote
2answers
82 views

Making conditionals in a function

I'm relatively new to mathematica, and need to make a function which takes a set of whole numbers as input, then iterates through all whole numbers and sorts them into two sets, one for numbers which ...
4
votes
1answer
51 views

Find the last element of a list under conditions

Let's consider the following simple data list ...
4
votes
3answers
441 views

Generating random numbers that keep a minimum distance

I want to create a list of n random integers from 1 to m, where all integers have to be at least a certain distance min apart (i.e. 3 integers out of Range[10], keeping a minimum distance of 2) ...
0
votes
1answer
31 views

Make a nested list of variable size

I want to try to make a list of lists of variable length in the following way ...
4
votes
2answers
53 views

Making polynomials representing frequency of a character in a list

Suppose I have the following list: l={{"a"}, {"a", "h"}, {"a", "d", "k", "r", "v"}, {"a", "b", "c", "k"}, {"a", "b", "c", "s", "u"}} this list made of the ...
6
votes
2answers
181 views

Extracting points from 3D plot that lie along an arbitrarily oriented line

Starting from i.e. the following 3d plot: d = RandomReal[1, {100, 3}]; ListPlot3D[d] Is it possible to extract points that lay along an arbitrarily oriented line,...
0
votes
0answers
71 views

How is this mathematical term called? [closed]

I need help in identifying the underlining mathematical term of my method (group membership of a Person to an ideal role) So I have Ideal values (for the ideal role) shown here in the 1st column (...
3
votes
2answers
188 views

How to find the positions of replaced elements in a list

I have two sets of elements a={3, 4.8, 5, 4.2, 3.6, 2.3, 4.5, 3.7} b={2.8, 4.7, 5.3, 3.5, 4.7, 2.8, 4.2, 3.4} and I create ...
6
votes
3answers
559 views

How to convert diagonal matrix to rectangular matrix

Suppose you have the following diagonal matrix: $\left( \begin{array}{cc} a & 0 \\ 0 & \{b,c\} \end{array} \right)$ How can the above matrix be converted to the following rectangular one?...
3
votes
1answer
72 views

Delete elements less than the last largest element

Here is my list. The first column contains its index and second column has data. ...
0
votes
1answer
40 views

When tabulate numbers from a list Mathematica changes them?

I would like to tabulate a list of numbers but Mathematica slightly changes these numbers?! Here is the list ...
0
votes
1answer
28 views

Defining a function that modifies a list [closed]

I have the a list A and I want to define a function f that takes out the $i$-th element from the list ...
0
votes
3answers
55 views

List manipulation: conditional result based on variable-length sublists, part deux

This is an outgrowth of this question. Suppose I have the following definitions: ...
6
votes
3answers
224 views

Sorting a list according to some pre-specified rules

Given a list such as {12,9,3,42,30,10,11,1,2} I would like to place only the multiples of 3 in the natural order without changing the order of the other ...
1
vote
1answer
59 views

For loop for two variable at the same time

Can I use for loop for two variables as example show below at the same time? for (int x = 0, y = 0; x < 10 && y < 10; x++, y++)
1
vote
1answer
47 views

Using ImplicitRegion over variable number of dimensions

I need code that creates a d-dimensional regions - where "d" varies. This simple example fails - ...
2
votes
1answer
35 views

Extracting list from a list of lists obtained using Solve function

After solving a set of equations I got a solution like the following using Solve[] function. ...
0
votes
0answers
61 views

I want to write $ k = \{k1,k2,k3,…,kn\} $. How could I do this? [duplicate]

When I write k = {k1, k2, k3, k4, k5}, it is ok. But I Want a general form, like k = {k1, k2, k3, k4, k5, ..., kn} how could I ...
1
vote
1answer
57 views

Transpose Error

I have this code: ...
4
votes
3answers
105 views

Set the parent of each child while iterating over a List

I'm still new to this language and have tried a number of ways with no success. I have a list of keys with values. These values are used to identify the parent of the current item. The list is ...
4
votes
1answer
38 views

Merge overlapped intervals in a list

I have a list of intervals: {{1,10},{8,15},{17,22},{24,36},{32,40}} I want to merge overlap pairs. For example, the first and second pairs are overlapping, so I ...
0
votes
0answers
15 views

Set conditions on SingularValueDecomposition

I'm a new user of Mathematica, and I am having some issues with SingularValueDecomposition. This function returns three matrices {u,v,w}, with v that is diagonal and u,w unitary such that u.v....
1
vote
1answer
32 views

Identification of linear combinations in a matrix

I have a matrix R which is having a dimension of 20 cross 20. When I extracted the rank of this matrix I got 16. I just wanted to which are these four rows are or columns which are dependent on each ...
1
vote
1answer
33 views

Phase choice for Singular Value Decomposition

I'm using SingularValueDecomposition to find the unitary matrices that diagonalize a given matrix (that I have). This decomposition is unique, up to multiplication for an arbitrary phase of each ...
2
votes
1answer
29 views

Plotting of ListLinePlot with proper legends and rendering

I have four data sets in the form {f(x),x} as, data1, data2, data3, data4. Now, I am trying to plot the four datasets using ListLinePlot. But I'm not able to get ...
3
votes
4answers
591 views

List comprehensions in Mathematica?

I'm looking for an implementation of list comprehensions in Python (nested for-in statement with destructuring and conditionals). Here's an example: ...
2
votes
1answer
31 views

Picking elements of a list

Suppose I have the following list, t = {{"e:r", "a", "p", "z"}, {"r:e", "a", "l", "o", "t", "y", "z"}, {"j", "o", "z"}}; I want to go through it and pick ...
0
votes
3answers
64 views

More general permutation of lists

For some arbitrary $N$, I would like to construct all permutations of lists of length $n \leq N$ such that the sum of each permutation list adds to a value less than or equal to $N$. Specifically, ...
2
votes
2answers
59 views

How to select the data in the following way?

I have the data which is obtained by joining the subsets with 12 rows. The subset has the following form: ...
3
votes
3answers
109 views

Is there an easy way to index by a binary vector / mask?

I would like to be able to extract elements from a list where indices are specified by a binary mask. To provide an example, I would like to have a function ...
6
votes
8answers
2k views

Simplify the code

I have a function that grabs the second part of the list and change it to times, ...
2
votes
4answers
73 views

Replacing function depending on the number of summed elements in its argument

I want to replace function f[x+y+z] by g[t] but I do not want to touch ...
4
votes
3answers
91 views

Collect the elements from a list by categories [closed]

I have a list of elemets with different variables {a,b,c,A,B,C}, list={3 b, A Cos[c]^2 Sin[a] Sin[b], -a E^(I a c) f[C, A]} Where f is some function. By assuming ...
4
votes
2answers
89 views

Sort a list of lists by increasing order of elements [closed]

What is the quickest way to sort a list of lists of integers, such that the first sorting criterion is the first element of the list, the next is the second element of the list and so on? E.g. The ...
1
vote
1answer
35 views

Extract position and rotation of arrows in streamplot

I have a streamplot like this ...
4
votes
3answers
159 views

List manipulation: conditional result based on variable-length sublists

Suppose I have the following lists: eqexp={a,b,c,d} eqval={e,f,g,h} signval={{},{1},{-1},{1,-1}} I want to create a new list of inequalities, where the signval ...
3
votes
2answers
55 views

Picking elements from a list

That's must be a very trivial question. Suppose we have the simple list data = {{-1, 0}, {0.2, 0.4}, {4, 0}, {0.3, 0}, {0.2, -0.4}}; Then, is there a quick and ...
6
votes
3answers
639 views

List Manipulation : {{{a,b},{c,d}},{{e,f},{g,h}}} into {{a,b},{c,d},{e,f},{g,h}}

Hi I'd like to transform the matrix : ...