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

learn more… | top users | synonyms (5)

1
vote
1answer
66 views

Using Select function based on data range

I am using Select to take values from a multidimensional list based on a previously calculated range. The list is of time and position of a particle over time steps done for multiple particles. The ...
3
votes
2answers
115 views

Customized ListPlot

I have an external data file containing the elements (t,x,y,px,py) of an orbit. Here is a sample data file. Now I want to ...
5
votes
2answers
314 views

Smallest element distance between two lists

I have a problem, where I generate two lists of points, and I want to see which points are the closest. If I just want to find which ones are exactly the same, I can use ...
1
vote
3answers
233 views

Command like “find” in Matlab [closed]

Is there a command working exactly like Matlab's find? I know that Pick might work, but I just want to give a logic condition ...
1
vote
2answers
192 views

How to speed up a For-loop [closed]

My code is the following: ...
3
votes
1answer
75 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
132 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
61 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
148 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
121 views
3
votes
0answers
51 views

Problem with MissingDataMethod

Given v = {2, 1, Missing[], 5, 7, 4}; I use EventSeries to replace the missing value with its predecessor ...
4
votes
3answers
134 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
50 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
113 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
61 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
205 views

DeleteCases In Mathematica

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

FindLinearRecurrence is not working for numerical complex number sometimes?

First FindLinearRecurrence definitely support complex number list, see ...
2
votes
1answer
77 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
224 views

Avoiding copies when modifying lists

Consider the following approach to modifying a list: ...
0
votes
0answers
35 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
423 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
172 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 ...
10
votes
3answers
424 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
31 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
85 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
194 views

Association Subtotals with Lists as Keys

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

How to make a Slash header in Grid?

Here is an example, ...
5
votes
3answers
170 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
147 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
145 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
356 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
148 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
103 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
108 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
32 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
20 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
200 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
196 views

Timing problem with ReplaceRepeated

I have the following data: ...
6
votes
2answers
139 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
342 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
65 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
52 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
68 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
110 views

Grouping the first two elements in a list of ordered triples

I have a long list of the form ...
3
votes
1answer
117 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
87 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
102 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
217 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
103 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 ...
4
votes
1answer
120 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 ...