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

learn more… | top users | synonyms (5)

15
votes
5answers
612 views

Easiest/most efficient way to delete duplicates from one list at the positions of another?

This question is somewhat related to How to efficiently find positions of duplicates? , although I'm interested in something a little bit simpler since I'm not really interested in a list of all the ...
0
votes
0answers
46 views

How to get x = 1.234 from {x -> 1.234}? [duplicate]

I'm a complete beginner in Mathematica (started a couple of days ago). I've solved a function using "Solve" and the result is this one: Out[1] = {x -> 0.000942939} How do I get the 0.000942939 ...
1
vote
2answers
84 views
0
votes
1answer
33 views

Choosing sets from Subsets[list] part 2

Piggybacking off of this question, say if I wanted to exclude sets which weren't the union of elements of the list of lists. For example: ...
5
votes
5answers
145 views

Choosing sets from Subset[list]

Say I have a set, S, and I take Subsets[S] (the power set of S). For example: S={a,b,c} Subsets[S]={{}, {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c}} How can ...
0
votes
0answers
21 views

Adding a list up to a starting value [duplicate]

The code that i need has a starting value of 5. From this starting value on a list of numbers is added consecutively like this list {-0.1,-0,3,-0.1,0.1,-0.1} ...
1
vote
2answers
283 views

How to optimize this code?

I am implementing a code that works correctly but it takes too much time. I did not see how to optimize it to be run quickly. Here is my code: ...
3
votes
1answer
58 views

How to collect elements in one list with the constraints provided in a second list

I wish to collect the items in the first list provided the constraints in the second list. For example in the lists shown below the first list shows a bunch of strings and the second list shows the ...
0
votes
0answers
52 views

(Sparse Array) Can Mathematica delete some of the 0's from a list?

This question continues form Can Mathematica delete some of the 0's from a list? This time I want to delete zeros before the first positive integer. I have a list: ...
3
votes
3answers
282 views

Mandelbrot set—efficiently iterate over a list of initial points

OP edit: This is a Mathematica-specific question about an approach it attempted for a fractal visualization problem described HERE. I'm using the Mandelbrot set there and here as an example, but the ...
0
votes
1answer
51 views

generation a nested matrix with a partly comparison of two other nested matrices [closed]

(this problem is maybe challenging because of its partly comparison) there are two nested matrices: mainmatrix1: ...
4
votes
3answers
201 views
1
vote
1answer
89 views

Manipulating Some Lists in Compile

Consider a list of lists, such as: Z={{1,4,3},{2,1,3},{3,1,4}} Z is an $n \times n$ matrix (here $3 \times 3$) which ...
1
vote
1answer
88 views

How to do this Function with compile

There is 4 lists, 3 of them are at same length (l0, l1 and l3). ...
11
votes
3answers
299 views

Partition a list based on specific elements? Grab the sublists beginning with a certain marker elements

Say I have the list {{a}, {0, 2, 5}, {5, 4, 1}, {a}, {1, 1, 0}, {1, 4, 2}, {3, 3, 0}, {a}, {3, 2, 0}, {1, 4, 1}} I would like to make sublists of everything ...
2
votes
2answers
48 views

Remove an element of a list [duplicate]

I want to check if any element of a list contains Missing["NotAvailable"] If so I want to delete the entire list. If I am correct I need to have some ...
6
votes
4answers
241 views

Average dataset with many repetitions?

I have a dataset where each item is of the form: <|"p1" -> x1, "p2" -> x2, "r1" -> y1, "r2" -> y2|> The interpretation is this: ...
5
votes
6answers
161 views

Replicate and expand a list

I have two lists a and b of the same length. And another list a2 which contains all elements ...
11
votes
1answer
242 views

Why does Outer sometimes return a packed array, and sometimes not?

For example In[342]:= test3 = Flatten[Outer[Plus, Range[1000], Range[1000]], 1]; // AbsoluteTiming Out[342]= {0.0198735, Null} returns PackedArray ...
2
votes
2answers
73 views

Multiplying a table with constants

I have a table with coordinates {{x1,y1},{x2,y2}} that I want to multiply with a separate constant for x and one for y so: ...
4
votes
1answer
199 views

List all possible elements of a set

I have this two sets: $A = \{\emptyset, \{\emptyset\}, \{\{\emptyset\}, \emptyset\}\}$ $B = \{\{x, \{x, y\}\} | x \in A, y \in A\}$ Now I want to list all possible elements that are in $B$. How do ...
1
vote
5answers
168 views

Do not expand matrices in Mathematica calculation

Here is an example of a problem I'm having. Consider that I have defined: omega={{p[t]},{q[t]},{r[t]}} x={{a},{b},{c}} R={{1,2,3},{4,5,6},{7,8,d}} What I would ...
30
votes
4answers
2k views

Using pure functions in Table

I need a table with the elements made of pure functions and list elements. This is a simplified example: I need a list as: ...
2
votes
6answers
196 views

How to extract the elements which the require the second elements to be the smallest?

Consider this code: ls1=Table[{x,Abs[Sin[y+z]]+Abs[Sin[x+y+z]]},{x,0,1,0.1},{y,0,Pi,0.1},{z,0,Pi,0.1}]; ls2=Flatten[ls1,2]; ListPlot[ls2] What I want is to ...
3
votes
2answers
81 views

`IntegerPartitions` without duplicates

I need to apply a function to integer partitions of many integers, but only the partitions without duplicate numbers. Select[IntegerPartitions[n], DuplicateFreeQ] ...
1
vote
2answers
84 views

Change function acting on sum to function acting on each object individually

Given a function like Conjugate[] acting on a sum, how I can change an expression like ...
2
votes
1answer
71 views

Interpolation of a multivariate function with duplicated 2D abscissa points

I want to interpolate a function q[a,b] I have a data file which has the form {a,b,q} a sample is following ...
0
votes
2answers
141 views

How to select 3-tuples of positions from a list with variable time-steps?

Below is a natural log list of ordered time data with variable time-steps. I would like a functional approach that selects 3-tuples of positions sublists based on the first selected elements that ...
2
votes
2answers
239 views

list of vectors with prescribed sum

Let $a\in\mathbb{N}^n$ and $k\in\mathbb{N}\!=\!\{0,1,2,\ldots\}$. How can I efficiently generate the list $$\{(a_1,\ldots,a_k); a_1,\ldots,a_k\!\in\!\mathbb{N}^n\!\setminus\!\{0\}, ...
1
vote
3answers
248 views

How to repeat a matrix on it's side?

I have the following matrix in Mathematica: mat = {{0,0,1,1}, {0,1,0,1}} I want to repeat this matrix N number of times on the side. For example if N = 3 then ...
3
votes
1answer
57 views
1
vote
1answer
22 views

Coefficient of function with general argument

I would like to obtain the coefficients of a general function f in a list. For example, the coefficient list of ...
13
votes
5answers
797 views

Permutations[Range[12]] produces an error instead of a list

This input: Permutations[Range[12]] Results in this (error) output: ...
1
vote
2answers
108 views

How to make function accept list of rules as an argument?

Considering the list of rules: r= {"a" -> "1", "b" -> "2", "c" -> 3, d -> 231, "e" -> 1.25}; I want to have a function ...
5
votes
6answers
377 views
2
votes
0answers
89 views

Fast construction and reshaping of large tensors

I'm trying to construct a large matrix which is derived from some higher rank tensor (the rank of interest to me changes case by case, so it needs to be a general method). Currently, the process of ...
0
votes
1answer
53 views

Timing and memory use is critical:fast partitioning of binary sparse array

I do experiments were I measure a signal, and I need to know at what time points it is above a threshold. If at a given time point, the signal is above the threshold, then a '1' gets put into the ...
-1
votes
0answers
43 views

Do loop, inconsistent results [duplicate]

Ive been at this problem for a couple of days now and no success. I'm very new to mathematica and hope someone can help. ...
1
vote
3answers
88 views

Polar histogram and bins

I have a list of polar coordinate points: list = Transpose[Join[RandomReal[{1, 60}, {1, 100}], RandomReal[{0, 2 Pi}, {1, 100}]]] I need to divide the ...
1
vote
1answer
42 views

How to make a substitution that involves a nested list? [closed]

I need to make a substitution for the variable $x$ from this. sub = {{x -> 2}, {x -> 5}} I want to give to $x$ one of these two values, say $2$. If I ...
-2
votes
1answer
37 views

Add a given scalar to every element in a list [closed]

I wish to add a give scalar to every element of a list. How can I do this? Thanks in advance.
-1
votes
1answer
38 views

How to convert nested lists into “standard” lists? [closed]

What is the easiest way to convert a nested list in a "standard" list? For istance how can I fastly convert {{16.5807}, {17.1458}, {16.1343}} into ...
3
votes
3answers
89 views
10
votes
8answers
796 views

Best way to emulate MATLAB's bsxfun using Map and similar functions

Given a matrix, we want to subtract the mean of each column, from all entries in that column. So given this matrix: ...
4
votes
2answers
63 views

Append fixed value to random selection of list

(This question might be an application of this other question, but there might be another solution specific to this application that I'm not aware of.) I am currently in a situation in which (in a ...
4
votes
4answers
215 views

Matrix of Columns, I want just a regular matrix!

I've been at this problem for a couple of hours now and no success. I'm very new to Mathematica I hope someone can help. I have the following ...
5
votes
4answers
133 views

Add to matrix missing elements (for list of time series)

This question is an extension of the 43122. I’ve looked through many interesting post (like this) but (as always) missed the direct matching. So the setting is simple: ...
1
vote
1answer
87 views

Continued fraction with different numerators [duplicate]

In Mathematica, is it possible to form the continued fraction of the following formula? $$ f = a_1+\cfrac{b_1}{a_1+a_2+\cfrac{b_2}{a_2+a_3+\cfrac{b_3}{a_3+a_4+\cfrac{b_4}{a_4+...}}}} $$