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

learn more… | top users | synonyms (3)

4
votes
5answers
762 views

Removing zero values from ordered pairs

I have some processed data, which are basically a collection of ordered pairs in the form: {{x1, y1}, {x2, y2}, ..., {xn, yn}} Ordered pairs which have either a ...
4
votes
1answer
298 views

Path queries for tree-structured data

Can anyone suggest documentation or tutorials for developing path queries and indices for (XML-like) tree-structured data? Suppose data is organized hierarchically in key->value pairs, eg: ...
3
votes
1answer
130 views

Select row from a table by column value [duplicate]

I have the following: animals = {{dog, black, 200}, {cat, white, 100}, {moose, brown, 500}, {zebra,black,100}} If this came from a SQL table called animals, ...
3
votes
3answers
157 views

Picking certain pairs according to a condition [duplicate]

I'm a Mathematica beginner and can't find out a solution to my problem. I have a list of pairs of numbers, for example something like this, but much longer: list={{2., 3.}, {3., 2.}, {5., 4.}, {4., ...
3
votes
5answers
371 views

How to combine some elements of a list?

In order to simplify my expression, I face a list manipulation problem. For example, given the input list ...
3
votes
2answers
411 views

hexList[[1]] returns a list of decimal numbers

Sorry for not being clear about this question earlier. I appreciate the answers I got, but the edits I made should make the question more understandable. I have been working with hex in ...
3
votes
1answer
206 views

Exchange axes in ListLinePlot

I'm sorry to do this right off the bat, but I have the following set of data: ...
2
votes
2answers
114 views
2
votes
3answers
138 views

Join matrix based on conditions

Given the following matrix: ...
2
votes
2answers
58 views

Specifying an array with a specific number of copies of two elements

To specify an array of length L in Mathematica, where each entry is someElement, I'm accustomed to writing: ...
2
votes
3answers
414 views

Generating pairs of additive and multiplicative factors for integers

Given an integer $n$, I want to get two lists: a) the set of pairs of the divsors $a,b$ into exactly two factors $n=a\cdot b$, b) the set of pairs $a,b$ of two summands $n=a+b$. The code I ...
2
votes
0answers
309 views

Generating a function which outputs possible chemical reactions

I want to make a list of chemical reactions and I write them down in a $\require{mhchem}\LaTeX$ format. They are of the following form $$NA_n^i+MB_m^j \rightarrow \hat NA_{\hat n}^{\hat i}+\hat ...
2
votes
3answers
222 views

Taking only particular subsets and doing calculations

I have subsets formed from a list using the Subsets command and want to do a particular calculation, lets say subtraction using the ...
2
votes
2answers
1k views

Calculating the distance between the coordinates in a list

I have a list of coordinates {{A[9, 4, 7], 0.0395174}, {A[1, 5, 0], 0.0163797}, {A[0, 7, 2], 0.0577425}, {A[2, 7, 5], 1.01313}} I want to find the distance ...
2
votes
2answers
286 views

Pattern test for variables during function definition

I am having a problem with pattern testing on variables during function definition ...
2
votes
1answer
172 views

List-operations only when restrictions are fulfilled (Part 2)

Consider the following: data={{{3544128000, 80}, {3544732800, 80}, {3545337600, 80}, {3545942400, 80}, {3545942400, 160}, {3546547200, 160}, {3547152000, 0}}}; ...
1
vote
1answer
92 views
1
vote
1answer
203 views

Compile with array operations

When I use the function f with only the Module ...
1
vote
1answer
144 views

Selecting every last element of a nested list

I couldn't find a similar question so I decided to ask this one. I have a nested list with many sublists of equal length. To make things easier let's say it's like that: ...
1
vote
1answer
103 views

Format Preservation of FullSimplify on Indexed System of Autonomous Equations

I currently have a large system of 150 autonomous differential equations. I've indexed a more managable dummy system of identical form, using Part to reference ...
1
vote
3answers
169 views

Separate an array in two arrays, the even and odd terms being separated in these two arrays

How can I separate the odd terms in one array and the even terms in another array,i.e., go from a={1,2,3,4} to aeven={2,4} ...
1
vote
2answers
219 views

Thread over a nested list top to bottom until non-list elements are found

I have a nested list: list = {1, 2, {3, 4}, f[a], {2, h[b]}} I would like to apply a function g to all elements of the ...
0
votes
1answer
37 views

save all inputs as list [duplicate]

I received three results of calculations: {k->0.190729} {k->0.197575} {k->0.249319} Could you help me write the results in the following form: ...
0
votes
1answer
105 views

A problem with set values

The following code is just an example to clearly explain my problem. Assume that : ...
0
votes
2answers
115 views

Total elements of a list that have a common first element [duplicate]

Possible Duplicate: List-operations only when restrictions are fulfilled (Part 1) I have a set of data like: ...
21
votes
5answers
498 views

More efficient way of generating list of occurrence counts?

Given a list, e.g., target = {a, b, c, b, c, d, c, d, e, f, a, h, g}, I want to generate a list containing the occurrence count of the corresponding element of the ...
16
votes
4answers
3k views

Finding Local Minima / Maxima in Noisy Data

I'm trying to find local minima / maxima in noisy data, consisting of data values taken at certain time intervals. Ideally, the function should take a pair of lists (one containing time values and one ...
20
votes
15answers
994 views

How do I extract the middle element(s) of a given list?

How do I extract the middle element(s) of a given list? Here is some code that works, but seems a little too long: ...
19
votes
3answers
762 views

How to extract the edge from a set of points

I have an accumulation of points representing a body as you can see in the image below. From this data I want to generate a list of points or a curve, which is the envelope. The first idea was a ...
17
votes
1answer
341 views

Underlying Algorithms for List Manipulation Functions

Does anyone know, or know of a link for the underlying algorithms used for list manipulation functions? Specifically: Union with and without the ...
27
votes
4answers
893 views

Filtering beat-to-beat heart rate data

From an experiment, I have a dataset of beat-to-beat heart rate data: a list of the time between each heart beat in [ms]. The data is measured using an infrared optic sensor at the finger tip. The ...
19
votes
3answers
555 views

DeleteDuplicatesBy is not performing as I'd hoped. Am I missing something?

Déjà vu: a new-in-v10 function should provide a better solution to an old problem, but my enthusiasm is curbed when I run timings. This time the function is ...
18
votes
6answers
6k views

How to find the position of elements in a list satisfying criteria

Say I have a list x={2,4,6,8,10} and I want to find out the positions of the elements that are greater than 7. ...
21
votes
5answers
6k views

How to find the phase difference of two sampled sine waves?

I'm trying to measure a phase difference between two Sine functions I've acquired with a computer. I'm uploading one of the .txt files with the data I'm working with here: txt file. To remove the ...
17
votes
4answers
292 views

Setting parts of a list

Suppose I have list a = Range[10] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} in which I want to set some elements to be a list ...
12
votes
10answers
600 views

How can I generate a nested array like this one?

Well, this is how the array looks like: I came up with this code: n = 10; Nest[ArrayPad[#, 1, 1 - #[[1, 1]]] &, {{1}}, n] /. {1 -> "*"} Any better ...
11
votes
2answers
197 views

Bug with SparseArray selector in Pick

I have created a notebook with two cells. This is the content of the first: ...
8
votes
4answers
270 views

Searching linked lists that contain lists?

Following the advice I've read here and other sites, I've been trying to use the Mathematica equivalent of a linked lists... ...
26
votes
2answers
676 views

DeleteDuplicates not deleting duplicates

It is not surprising that DeleteDuplicates[{5,5.}] returns {5,5.} because DeleteDuplicates ...
18
votes
3answers
711 views

Strip waste braces in nested list

I have nested lists wherein there are a lot of waste levels which looks like l = {{{{{{2, 2}}, 3}, 2, {{2, 33}}, 4, 5}}}; I would like to reduce it to somthing ...
18
votes
1answer
430 views

Using Transpose with a list as the second argument

I'm having difficulty understanding the Transpose function. I know what the transpose of a matrix is, not a problem, and I see that applying the ...
16
votes
1answer
320 views

Are there advantages to using additional arguments of common functions rather than alternative ways of calculating with lists?

(Apologies for the long question title.) One of the interesting, if sometimes confusing, things about Mathematica is that there is always more than one way to do things. Even intermediate users can ...
12
votes
4answers
474 views

Calculate proportion of values for dates

At work, we were discussing when is it the best time to change to winter tires for bikes and/or cars. Using WeatherData[] and ...
10
votes
2answers
293 views

Select cases from a list

I have a list in the form : {1,1,1,0,-1,-1,1,1,1,0,0,0,0,-1,-1} No I'm trying to select only those sequences which start with 1 have a zero (or many zeros) ...
10
votes
1answer
180 views

Drop selection of columns from a ragged array

I have an application where I need to drop some arbitrary list of columns from a ragged array (where of course the shortest array rows have at least all the specified columns). E.g., given a ragged ...
9
votes
4answers
517 views

Using Position (which requires a pattern) in the same manner as Select (which requires a criterion)

I am using Mathematica7. I have a list of lists (creatively named list in the following sample code) containing data. I would like to find the positions of the ...
7
votes
4answers
505 views

How make f[{x,y}] evaluate as f[x,y]?

I frequently encounter the situation where I have a function of two real variables defined, e.g.: f[x_, y_] := 9 - x^2 - y^2 But then I need to feed into ...
14
votes
8answers
518 views

How to neatly get the sum of symmetric elements in a list?

The task is to compute symmSum[{a, b, c, d, e, f}] (*==> {a+f, b+e, c+d} *) symmSum[{a, b, c, d, e}] (*==> {a+e, b+d, c} *) My clumsy solution is ...
12
votes
4answers
1k views

Reshape vectors exactly like in MATLAB

This gives a 64×1 column vector in Mathematica: ...
12
votes
7answers
649 views

DeleteCases on list of Strings

Consider the following: data={"AB","CD","AF"}; Now I would like to delete all String from data which starts with "A". ...