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

learn more… | top users | synonyms (5)

3
votes
2answers
174 views

How to print of all ternary number of 100 digits?

For example, to print all ternary number of 3 digits I would do something like this Do[Do[Do[Print[i, j, k], {k, 0, 2}], {j, 0, 2}], {i, 0, 2}] to return 000, ...
9
votes
1answer
157 views

Coloring spiral structures

In a previous question Original post @Julian S. proposed a method for coloring spiral structures. However this method works well only if the two spirals do not merge together. For example, for these ...
5
votes
3answers
360 views

A simple list question

If I have list1={x^a, x^b, x^c} and list2={1,2,3}, how do I substitute one into the other to get ...
4
votes
5answers
154 views

Opposite of Differences

I want to add the successive the elements of a list. As we know the operator "Differences" performs the difference of the successive elements of a list. Is there a function which performs the opposite ...
0
votes
1answer
157 views

How to fit multiple Gaussian peaks to data [duplicate]

How would I fit this data with Gaussian Peaks? I have tried various codes but none have even worked. Note: If I do Log[data], the peaks are more visible (I have tried the method from here but it got ...
1
vote
1answer
116 views

Fitting multiple peaks

I am using the code found here to fit multiple peaks of a large dataset which I don't know anything about. This was the only code I could find on the internet to do such a thing. So this is my attempt ...
3
votes
1answer
34 views

Difficulty with LevelSpec. Product of empty set should be 1

I have a matrix newm = {{{}, {}, {-p}}, {{d}, {e}, {p}}, {{g}, {h}, {i}}}; MatrixForm[newm}; whose elements are lists. I would like to multiply the elements of ...
0
votes
0answers
21 views

Remove background from multipeak data [duplicate]

Let's say I have a a very large list of data in the format {{n,f[n]}} so something like {{1,600},{2,700},{3,1100}...} and if this data is plotted, then it will look like a sum of Gaussian functions+a ...
5
votes
3answers
242 views

Removing background from peak function

Let's say I have a a very large list of data in the format {{n,f[n]}} so something like {{1,600},{2,700},{3,1100}...} and if this data is plotted, then it will look like a sum of Gaussian functions+a ...
10
votes
4answers
202 views

Timing problem with ReplaceRepeated

I have the following data: ...
6
votes
2answers
371 views

Exception with GatherBy: gathering complex conjugates

I want to gather the complex-conjugates that are in a list, but with an exception: only if the imaginary part isn't zero. For example: ...
11
votes
3answers
370 views

get position index for all element in a list

For example mat={{a,b},{c,a,a}} How to write a function posindex that posindex[mat] will ...
-1
votes
3answers
69 views

Multiply equations in lists

list = {x + 1, x - 3, {x - i, x + i}} The last two elements should be multiplied. Desired output is: {x + 1, x - 3, x^2 + 1} ...
0
votes
1answer
56 views

Multiply elements within a list [closed]

How do I multiply elements within a list? list = {{1}, {2, 3}, {4, 5, 6}, {7}, {8,9}} Desired output: {1, 6, 120, 7, 72}
2
votes
1answer
109 views

How to take every second element [duplicate]

If I have {1,2,3,4,5,6}, how do I take all the second elements into a new list? So I want a list like {2,4,6}.
4
votes
1answer
127 views

Grouping the first two elements in a list of ordered triples

I have a long list of the form ...
3
votes
1answer
124 views

Efficiently generating plots from lists of differing lengths

I guess this is more of an informatic question. A quite complicated function of mine generates me a list of valid points, depending on a parameter, like this: ...
5
votes
2answers
90 views

Overlap between lists of sublists with different dimensions

I have two lists of sublists. The sublists in the first list contain three elements while the points in the second list contain four e.g.: ...
2
votes
1answer
109 views

Collecting Data in table

I wrote a program (with help of the stackexchange) that is supposed to run in a loop. Each time the program runs, it exports a small data. Is it possible to generate a table where each run adds the ...
7
votes
5answers
237 views

Referencing previous elements in the same List

I'm looking for a way to reference an element within a List to get another element in the same parent List. I can't really see ...
1
vote
1answer
144 views

How to find period of a discrete sequence?

For example, {1,2,3,4,5,6,7,8} has period 1, the base is {1} {1,2,4,5,7,8,10,11} has period 3, the base is {1,2} I ...
5
votes
1answer
130 views

Why does my MapThread expression fail in this case?

This morning, I opened one of my previous notebooks and evaluated it. Surprisingly, the code produced an error. This took me a whole four hours to find the problem and it is with ...
7
votes
2answers
153 views

Allocate amount A according to the distribution of amount B

I have a cost that varies by category and date. I also have the counts of each item type within each category and date. I want to distribute the cost to each of the item types. I'm trying to use <...
2
votes
2answers
98 views

How to transform data in character form into a sensible form?

I have a data output from a device in a form of a string. I need to transform it into such a form that I can work with it, such as plot columns with respect to one another and such. After a apply <...
3
votes
0answers
83 views

Delete many elements of a list at once [closed]

I have a list of points in 2d: myList = {{x1,y1},... , {xn,yn}} And a range of points I want to remove from the list, for instance: ...
1
vote
1answer
35 views

Select on 3D-table along diagonal

I have the following data set on the form (x, y, z) ...
2
votes
1answer
62 views

Table: calculate the intermediate variable but not list them

I want to list {a,c} but c is depend on b, suppose the dependence on ...
14
votes
4answers
404 views

A replacement problem

list = {1, x, 3, x, 4, x, x, 3, 4, 3, x, 2, 3, x, 8, 7}; If there is exactly one integer between two x I want to replace it with y: ...
10
votes
1answer
167 views

How to write this pattern in Pick function

Suppose I have a list called mask composed of 1,2,3,...n. n is different in different situation. Let me takes n=3 for demonstration ...
18
votes
6answers
861 views

Recursively appending elements to a list

In wanting to demonstrate the power of Mathematica, I wanted to show my 11-year-old son how we could validate that his sequences homework was correct. We could generate the next value in sequence in a ...
0
votes
1answer
178 views

How to get all possible combinations of this list? [closed]

I'm trying to get all possible combinations of {0,-1} for a certain length. So let's say I want length 2. Then I want my output to be ...
4
votes
2answers
110 views

Ordering and summing elements of a list based on their indexes

Suppose I have a vector. I assign to every vector index a four-element array, in such a way that index i corresponds to ...
5
votes
0answers
57 views

SimilarityRules for SequenceAlignment of two lists

I am trying to use the SimilarityRules option of SequenceAlignment to customize its output. This works perfectly for strings, ...
2
votes
1answer
49 views

ndsolve interpolatingfunctions not shown/evaluated

Using this technique from Simon, I want to solve a matrix differential equation with a matrix that contains an explicit time-dependence(our variable), but I want to be able to solve this problem for a ...
5
votes
1answer
97 views

ListConvolve with Padding -> Fixed?

The built-in function ImageConvolve takes a Padding option that "specifies what padding to use when extending beyond the ...
6
votes
3answers
205 views

Creating new lists

We have the following list data = {{1,2,3,4,5}, {6,7,8,9,10}, {11,12,13,-1,14}} If I want to create a new list containing the first and the fourth elements of ...
3
votes
1answer
86 views

How to insert into a nested list/association?

Considering following nested structure: ...
2
votes
1answer
50 views

Create array of “positions”

How do I create an array a of generic depth $n+1$, such that exactly: a[[i1]][[i2]]...[in]] = {i1,i2,...,in} ? In words, such ...
3
votes
1answer
124 views

Way to generate all multisets

I have a set $\left\{\{1,2\}, \{3,4\}, \{5,6\}, \{7,8\}\right\}$ (for example) and want to generate all sets of $n$ elements with repetition but without counting the same multiset twice. So I want my ...
4
votes
1answer
69 views

How can I “permute” an ordered pair over all the permutations of say $S_4$?

I want to make an action table of the symmetric group (say $S_4$) acting on the set of unordered pairs of distinct vertices of a square. I have the list of such pairs: ...
4
votes
3answers
225 views

Cleaner way to find a list item within an array.

So I have a list somewhat like this: ...
7
votes
1answer
185 views

Remove leading and trailing zeros from a list

This functions and gives the desired result: {1, 0, 2, 0, 0} /. {x___, 0 ...} :> {x} {1, 0, 2} But with leading zeros it doesn't: ...
0
votes
1answer
98 views

How to plot two lists in the same graph maintaining the scale of the points?

I need to plot two lists of complex numbers in the same graph to show some results, so I'm using the following lists to do that: ...
7
votes
6answers
385 views

How to select sub-lists having at least one element that matches a pattern

This will probably be a very easy question, yet although I did find a relatively similar one, I couldn't use the answers there to solve my problem (I'm still a novice). I'm simulating 10 blocks of ...
4
votes
0answers
108 views

Bug in ListLinePlot[] when Filling up and down?

I'm trying to understand this apparently incorrect Filling behavior in ListLinePlot[]. Evaluating this ...
3
votes
5answers
239 views

Loop over list of lists

Greetengs,im totally new here. I cant fined answer at other simular questions, so i create a new one. I have optical spectra in the following format: ...
3
votes
1answer
126 views

Using Select with Alternatives

I want to select the elements of a list like: ...
3
votes
2answers
118 views

Swap LHS's (or equivalently RHS's) of two rules in a list

Assume I have a list of rules, each of the form $a_i \rightarrow b_i$. What is the best way, for some $i$ and $j$, to swap $a_i$ with $a_j$ (or equivalently, $b_i$ with $b_j$). Currently, I have ...
14
votes
4answers
289 views

Fast Selections Testing on Inequality

Is there a functional idiom for fast selections testing on inequality? For example, finding values from list a & b where the key is less than or equal to a value, in this case 4 or 9. An ...
4
votes
1answer
233 views

Select elements of list

I have a list of lists list={l1,l2,l3,l4,...}; and two elements e1,e2. I want to select from lists ...