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
295 views

DeleteCases In Mathematica

I want to eliminate all the sub lists containing exactly two positive numbers? My list is ...
3
votes
1answer
56 views

FindLinearRecurrence is not working for numerical complex number sometimes?

First FindLinearRecurrence definitely support complex number list, see ...
2
votes
1answer
83 views

TakeWhile for nested list

I have a nested list of time and position for multiple particles over multiple time steps. I want to cut all the time steps off (for each particle) after which the $z$ coordinate goes above a certain ...
8
votes
1answer
227 views

Avoiding copies when modifying lists

Consider the following approach to modifying a list: ...
0
votes
0answers
36 views

Manipulating a symbol via its name [duplicate]

I'm trying to change the entries of a list. The problem here is that I only know the symbolname of the list for example name="x" , where x is defined as ...
11
votes
5answers
448 views

How to sort list of mixed types of elements with each type a specified canonical order?

For example, here is a list {{1, "u"}, {6, "d"}, {3, "u"}, {4, "d"}, {2, "u"}, {5, "u"}, {3, "d"}, {1, "d"}, {4, "u"}, {2, "d"}, {5, "d"}, {6, "u"}} The ...
4
votes
1answer
205 views

Random Partitions

I want to write a function RandomPartition to partition a vector of length n into p partitions of varying (random) lengths. For example with ...
11
votes
3answers
492 views

How do you concatenate matrices? And how do you make block matrices?

This is pretty trivial to do in Matlab, but I have not seen a function for it in Mathematica. Here is how you can do it with Join and ...
-1
votes
1answer
34 views

Producing a list [closed]

Table[x, {i, 5}] In mathematica 9 this results in {x,x,x,x,x}, but in v10 it's {1,1,1,1,1} ...
4
votes
1answer
89 views

Efficiently traversing a list

Suppose I have a large list of algebraic expressions, sorted by their equivalent numerical value (under a certain set of assumptions). Some of these expressions are identical, but commands like ...
10
votes
3answers
208 views

Association Subtotals with Lists as Keys

I have the following Association: ...
11
votes
2answers
222 views

How to make a Slash header in Grid?

Here is an example, ...
5
votes
3answers
189 views

DeleteStopwords in other languages?

I saw that in new version of Mathematica there is an interesting function: DeleteStopwords that deletes stopwords from a list of words, but this function is only ...
3
votes
2answers
167 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
153 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
358 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
153 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
147 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
239 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
201 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
363 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
68 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
54 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
96 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
123 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
89 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
235 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
138 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
129 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
96 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
80 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
61 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
402 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
162 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
848 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
153 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
109 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
48 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
91 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: ...