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

How to speed up a For-loop [closed]

My code is the following: ...
3
votes
1answer
78 views

Who can explain the strange behavior of command “Last”

Situation I use Last to extract the last element of an expression. Let poly=a+b*c+Log[a]+z. Problem When Using ...
4
votes
3answers
144 views

List of functions to list of parameters

I am working in a Dataset and I need to create a function for a ChartStyle option of a ...
4
votes
1answer
80 views

apply binary operation to all adjacent pairs

Is there a built-in or more efficient approach than using Partition to apply a binary operation to adjacent pairs of elements? That is, is it reasonable to be ...
7
votes
4answers
153 views

Reverse DeleteDuplicates using Information from Tally

I have a list of values, e.g., {1, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 5}. I delete the duplicates with ...
3
votes
3answers
133 views
3
votes
0answers
59 views

Problem with MissingDataMethod [closed]

Given v = {2, 1, Missing[], 5, 7, 4}; I use EventSeries to replace the missing value with its predecessor ...
4
votes
3answers
137 views

Inserting an indexed string into the 1st position of each pair in a list of pairs

How do I insert "Z" and then a number going from 1 to end (without space) in a list? I have the following list: Input: ...
1
vote
2answers
55 views

Bin data from an imported excel file by adding 5 elemets of y axis each [closed]

So i imported a file from excel and viewed it as a grid. but now i need to add groups of 5 elements from the y axis and plot them against every fifth entry from the x axis. Thanks Edit: Sorry about ...
1
vote
2answers
118 views

Trouble adding elements to array [closed]

I need to generate array and export it to file. For n = 1 , second element must be 0 For n = 2.. 819, second element must be 1 For n = 820.. 1637, second element must be -1 For n = 1638.. 16384, ...
1
vote
1answer
69 views

Filter two lists of 2D coordinates such that only those that have a nearby neighbour in the other list are collected

I have two sets of coordinates: GreenPairs.xls RedPairs.xls I'm only interested in the coordinates that have a very close (overlapping in the plot below) different coloured neighbour. The ...
3
votes
2answers
330 views

DeleteCases In Mathematica

I want to eliminate all the sub lists containing exactly two positive numbers? My list is ...
3
votes
1answer
57 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
229 views

Avoiding copies when modifying lists

Consider the following approach to modifying a list: ...
0
votes
0answers
39 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
457 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
215 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
558 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
90 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
213 views

Association Subtotals with Lists as Keys

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

How to make a Slash header in Grid?

Here is an example, ...
5
votes
3answers
195 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
176 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
160 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
361 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
156 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
170 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
118 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
36 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
252 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: ...
7
votes
2answers
375 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
374 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} ...
-1
votes
1answer
59 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
114 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
128 views

Grouping the first two elements in a list of ordered triples

I have a long list of the form ...
3
votes
1answer
126 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
110 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
239 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
151 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
99 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
102 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) ...