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

learn more… | top users | synonyms (5)

1
vote
2answers
51 views

List of options

It seems this should be easy, by I just can not figure out how. I want to have a function that I can pass a list of options to, or use a default. I have found two very similar questions, but I can't ...
15
votes
5answers
350 views

Partitioning a list when the cumulative sum exceeds 1

I have a long list of say 1 million Uniform(0,1) random numbers, such as: dat = {0.71, 0.685, 0.16, 0.82, 0.73, 0.44, 0.89, 0.02, 0.47, 0.65} I want to ...
10
votes
6answers
277 views

Split according to List and apply rule

I have a list which looks some thing like this {a1, a2, a3, a4, a5, a6, a7, a8, a9, a10} Now I want to split it according to lengths ...
0
votes
1answer
44 views

How to make an empty list inside a module program? It consatly spews errors [duplicate]

Okay, so, I'm trying to write a program within the module. It goes like this: create empty list, join it with a sample from a certain set called MyList, and then repeat it certain number of times. ...
3
votes
0answers
46 views

Weird behaviour for a vector InterpolatingFunction inside an NDSolve

I have run into some weird behaviour on the part of NDSolve which I find pretty bizarre and which I would like to understand better. Suppose, for the sake of ...
6
votes
2answers
843 views

How to create a histogram of annual events, such as cherry blossom time

I have calculated blooming and ripening times for a specific variety of plant, based on actual temperature data from over 40 years. I would like to create two histograms on a single axis; one for ...
3
votes
0answers
102 views

Efficiently generating tuples with Outer

I'm trying to efficiently generate tuples of lists of objects that satisfy a given criterion. The similar questions that I have found on this website end up finding a specific workaround for the given ...
7
votes
1answer
115 views

Add terms to nested list

Suppose I have a nested list of the following: list={{1,2},{5,8},{4,1}...} I would like to add a number to each first term of the list. The output would be ...
1
vote
1answer
53 views

How to refer a number in a list with two columns, first one is a number and the second one is empty? [on hold]

Let's say, I have defined a list as list = {{-31, -31}, {52, }, {34, -11}, {-38, }, {78, -44}, {-36,14}, {-9, 98}, {33, 6}, {82, 99}, {-85, -10}} As you can see, ...
2
votes
0answers
42 views

Automatic text-wrapping in labels in `TimelinePlot`

Part-related to this question and part-related to this one, I would like to make use of the new features of TimelinePlot in 10.3, but would like to incorporate some ...
3
votes
1answer
71 views

Calculating products of given length of two matrices

I have the following problem to solve. Let us have two given square matrices $A$ and $B$ of the same size and a positive integer $n$. I would like to produce all products of length at most $n$ of ...
0
votes
0answers
30 views
1
vote
1answer
33 views

Reverse element in nested list [on hold]

Suppose I have a list as the following: list={{1,9},{7,0},{8,6}....} How can I reverse the element in such way that the output would be the following: ...
8
votes
6answers
2k views

Check if two lists are equal in any order

Suppose I have two lists, how can I efficiently check if the two lists are identical up to permutations of the elements? For example I would like the function to output: ...
0
votes
0answers
30 views

Group nth Subelement of Nested List [closed]

I'm trying to group the nth subelements of a nested list together. The input would look something like in={ {a,b,c,d}, {e,f,g,h}, {i,j,k,l} } and the ...
2
votes
0answers
42 views

Transposing a table [closed]

I created this table so that it is a collection of 5 different functions that I need. It outputs the values that I want, however, I cannot figure out how to get the orientation right. I would like to ...
1
vote
2answers
44 views

Create an indexed list of functions [duplicate]

I am trying to use a Table to create the following object: {f[#,1]&,f[#,2],f[#,3]} The obvious doesn't work, ...
1
vote
1answer
28 views

How to create sublists of consecutive elements? [duplicate]

I have a list of elements, for example: myList={5, 12, 16, 18, 19, 24, 28, 29, 31, 32, 35, 42, 43, 47, 50, 53, 60, 61, 62, 64, 79, 82, 84, 92, 105, 128, 136, 153, 154, 155, 156, 158, 159, 160, 164} ...
7
votes
2answers
189 views

How to implement JoinTo efficiently?

AppendTo is not efficient so I'm not quite sure of the best way to implement its analogue for joining (e.g. in python this would be extend function). So how can this be improved: ...
0
votes
1answer
44 views

How to apply a user-defined function to a list [closed]

I'm using Wolfram | Alpha Pro; I have a function f[n] = 351n^(-0.7); How do I apply it to each element of a list like {2, 9, 22}? f/@{2, 9, 22} just results in ...
14
votes
3answers
424 views

Generating Tuples with restrictions

I am interested in a certain subset of all tuples. Generating all with Tuples and then filtering is wasteful, and will "blow up" very quickly. For a concrete ...
4
votes
1answer
136 views

How do I disable that Mathematica orders terms in lexicographic order?

I have matrices with entries where the order of the entries is important. Unfortunately Mathematica resorts terms in products in a lexicographic order. For example, ...
5
votes
2answers
240 views

Max of imported numerical data will not work

I loaded a list with 400,000 values from a file. The list was loaded correctly as I can get it's length (by Length[]) and I can also plot it. Why can't I get the Max or Min of this list though? When ...
4
votes
0answers
56 views

Create an adequate 'training set' to train a ClassifierFunction which performs the role of the built-in `SubsetQ`

I am trying to "grow" my own SubsetQ function using Machine Learning methods. My cSubsetQ when given two lists (listA and ...
5
votes
3answers
164 views

How to replace an element in a list with an element in another list with matching indices

I have a list like this l = {1 + 2*s, 2 + 3*s, 4 + 1*s}, and I have calculated s = {1, 2, 3}. I need to replace ...
1
vote
0answers
21 views

Append in For loop doesn't work [duplicate]

I want to simulate a projectile motion under the effect of air resistance by using Append in a For loop, but there appeared to be no changes in the two lists I defined for storing horizontal and ...
2
votes
1answer
31 views

Encoding/Decoding matrices as integers, integers as matrices [closed]

I want to convert large binary matrices of m x n dimensions into integers, and then to convert these integers to the original matrices. I attempted the following: ...
0
votes
0answers
29 views

DeleteDuplicate from a list with {x == y, y == x} -> {x == y}; [duplicate]

How can I tell Mathematica that it should delete equal elements from a list, which aren't in the same order. For example list={x == y, y == x} ; should become ...
9
votes
2answers
155 views

Position with test for list of lists [duplicate]

Why do I get this error message? It seems to me that the level specification should have done the job. ...
1
vote
1answer
62 views

Monitoring a matrix with changeable elements as Manipulate in plotting [closed]

If we remember, Mathematica has an ability to show a Psudo-window of plots for monitoring the effects of some changeable parameters in the functions. For example ...
9
votes
3answers
383 views

Generalization to AllTrue, AnyTrue and NoneTrue

I am wondering if there is a natural Mathematica way to generalize those functions. To be specific, All three functions AllTrue, ...
10
votes
4answers
262 views

How to make FlattenAt work with Span?

This works: MapAt[h, {a, {b, c}, {d, e}, {f}}, 2 ;; 3] (* {a, h[{b, c}], h[{d, e}], {f}} *) but this doesn't: ...
2
votes
4answers
55 views

Partition list into sublists of decreasing length [duplicate]

For example, I would like to partition {1,2,3,4,5} into {1} {1,2} {1,2,3} {1,2,3,4} {1,2,3,4,5} with just one line of code. ...
1
vote
1answer
74 views

diagonalization function

If we have a matrix m which is n*n, how can I do mm=U^dagger m U which is a transformation ...
2
votes
2answers
93 views

plotting eigenvalues with devoted level coloring

I am about to plot eigenvalues of a matrix versus varyingj's. ...
3
votes
2answers
108 views

Implementation of a matrix formula

For the Bezier surface, which owns the following matrix definition: where, $B_{n,i}$ denotes Bernstein-basis. ...
8
votes
1answer
94 views

Duplicate-free results of permutations + constant list

Given a constant list const, e.g. const = {-(15/2), -(13/2), -(17/2), -(15/2), -(13/2), -(11/2)} of length ...
2
votes
2answers
91 views

Implementing an affine cipher

I am trying to create functions for encoding and decoding an affine cipher in Mathematica. I have written these two functions: ...
3
votes
1answer
23 views

List of sound objects indexing

I am creating a list of sound objects: tones={}; For[j = 0, j <= 40, j++, tones = Append[tones, Play[Sin[2*Pi*t*500/Exp[-0.1*j/20]], {t, 0, 1}]]]; Each ...
3
votes
2answers
65 views

Assigning multiple solutions different replacement names

Let's say we are solving a homogeneous differential equation, such as $$y^{\prime\prime} + a y^{\prime} + b y = 0$$ with characteristic equation $$s^2 + a s+ b = 0.$$ Using the ...
8
votes
9answers
338 views

Positions of elements in the initial flattened list in a split list

Say, we have a list: m1 = {2, 2, 7, 0, 7, 7, 2, 2, 2} It can be split easily: ...
6
votes
3answers
240 views

How can I create a random symmetric matrix in this way?

The most straight forward way for me to think about is like this: ...
-2
votes
2answers
100 views

How do I write a function that returns the atomic mass given an element's symbol?

I want to write a function atomMass that, given an element's symbol, say "He", returns the atomic mass for the element (in this case ~ 4.0026). I do not even know where to start with this question. ...
4
votes
2answers
158 views

Subset-type function construction

This is probably a very straightforward thing I am missing, and probably also a duplicate(!), but I can't for the life of me think how to do this cleaner. I want to achieve what ...
2
votes
0answers
17 views
0
votes
1answer
30 views

Picking some elements of a matrix and generating another matrix [duplicate]

If we have a nested matrix as: start={ {{1, 2, 2, 3}, {1, 1, -2, 1}, {3, 2, 2, -I}, {1, 2, 0, -I}}, {{3, 4, 4, 0}, {1, 1, 4, 1}, {3, 3, 4, -1}, {1, 1, 2, I}} } ...
2
votes
1answer
36 views

wrong result of an iteration related to replacement and comparing

We have two nested matrix and a code for replacement following an equality as: ...
0
votes
0answers
59 views

Approaching infinity

I'm using Mathematica to visualize the autocorrelations of all kinds of wave-types. Obviously, my waves aren't infinite and don't have infinite periods though, so the autocorrelation I get is a ...