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

learn more… | top users | synonyms (3)

17
votes
5answers
613 views

Map-Thread-Through-Apply a list of functions onto a list of (lists of) values

I have a list of functions: fns = {f, g, h} and a list of triples: ...
6
votes
3answers
244 views

Importing and manipulating strings - time data

I have a list of time durations, which are strings of the form: "hh:mm:ss". Here's a sample for you to play with: ...
6
votes
1answer
258 views

How to compile Map and MapAt

I have a long list (say, million of elements, like this one: {{{1.0, 2.0}, 3}, {{4.0, 5.0}, 6},...} I would like to compile a function ...
8
votes
1answer
268 views

Elementwise, compilable min function

I am trying to implement efficiently a transfer-matrix like algorithm. On each iteration, I have two vectors $x=\{x_1,\dots,x_n\}$, $y=\{y_1,\dots,y_n\}$ with real numbers and I need to compute the ...
2
votes
2answers
147 views

Constraining a random function

This question is a follow-up from here. I have a function that generates a list of correlations between some random variables: ...
4
votes
1answer
224 views

Timing differences between multiple executions of identical code

I have a list of pairs of numbers and I'd like to change the sign of the second element in each pair i.e. $(a,b)\rightarrow (a,-b)$. I'm sure there are many ...
3
votes
2answers
435 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 ...
1
vote
2answers
247 views

Combining lists with common elements efficiently [duplicate]

Possible Duplicate: Computing the equivalence classes of the symmetric transitive closure of a relation I am required to process sets consisting of 2-element subsets of integers by ...
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 ...
6
votes
2answers
290 views

Merging different size, different order table

I'm a beginner in Mathematica, so this may be a simple request. I have generated some columns of names and data. I want to merge them into a single list of names, with a column for each attribute. ...
0
votes
1answer
827 views

How to get data from For loops to plot it?

How can I get data from For loops to use in ListStreamDensityPlot? I tried AppendTo, but it ...
9
votes
2answers
250 views

Combining nested lists that meet certain criteria for a permutation

I have the following list representing a permutation on 26 characters: ...
12
votes
1answer
466 views

How to extract and replace submatrix of a doubly-periodic matrix?

How can I effectively extract and replace a rectangular subpart of a toroidal matrix, i.e. one where boundaries are connected at opposite ends? Since the submatrix can overhang the edges, a simple ...
1
vote
3answers
268 views

Replace values of a list containing words and numbers

I'm trying to import some data in a .txt file which contains numbers and words. I import a list which consists of four rows of measured data acquired with an oscilloscope, but the acquisition program ...
1
vote
2answers
247 views

Proper way to deal with lists and map

So, I wanted to do something that I assumed would be really simple. Given two lists, $A = \{a_1, a_2, ...\}, B = \{ ... \}$, I wanted to take a function $f(a, b)$ and generate a list with $\{ f(a_1, ...
6
votes
3answers
384 views

Argmax in a List

I have a sequence of 100 lists. A sample list, list[1], looks like this: ...
19
votes
3answers
413 views

How can I regroup elements in a list into a tree based on their values?

I have a list of elements in an outline, here is an example that is only 3 levels deep: ...
7
votes
4answers
155 views

Is there a good way to map a function over a list to lists exclusively of a certain depth?

Let's say I have some ragged list. If some elements have some depth $n$, then is there a way I can map a function to only those elements? I.e., for some list foo, ...
6
votes
2answers
306 views

Conditionally replace rows in lists

I have a sequence of matrices/lists ...
3
votes
1answer
160 views

How can I find the average of the ordinate of an indefinite number of lists of points?

Suppose that I have three lists: list1 = {{0, 1}, {0.1, 10}, {0.2, 100}}; list2 = {{0, 1}, {0.1, 10}, {0.2, 100}}; list3 = {{0, 2}, {0.1, 20}, {0.2, 200}}; In ...
6
votes
2answers
192 views

DateList Segmentation of data

I've been trying to separate large segments of DateList formatted data (years worth at a time) into individual days using the Split function. The data has the form: ...
7
votes
0answers
239 views

Using Compile to speed up Function with PermutationProduct

I have the following fairly simple routine dot involving PermutationProduct that I wish to speed up using ...
34
votes
6answers
2k views

Find zero crossing in a list

I'm looking for a function that finds the index of the zero-crossing points of a list. Before I go making my own subroutine to do this, I was wondering if anyone knows of any built-in Mathematica ...
9
votes
2answers
2k views

How to get Matlab data imported with the same dimensions?

I have some Matlab image data with the following dimensions (output is from Matlab): >> size(im) ans = 86 86 3 45 The data imports just fine ...
6
votes
1answer
379 views

Count sublists which match pattern

I have a list which looks like this: data={{12,0},{0,0},{20,1},{0,0}, {0,-1}}. Now I would like to count the number of sublists which: have both slots zero the ...
2
votes
1answer
149 views

How to arrange elements of a list

A file consists out of (x,y,z) data and I need the z-values arranged like this: {{z[1],z[2],...z[idimx]},{z[idimx+1],z[idimx+2],...z[idimx*2]},{....}} With ...
15
votes
6answers
1k views

Best way to extract values from a list of rules?

Mathematica has a lot of list manipulation functions, and, also because I don't work with lists often, at times I'm a bit lost. I'll find a way, but I'm sure it's not the most efficient. Case in ...
5
votes
6answers
359 views

How to change specific values in a List [duplicate]

In a list lst I want to change all values > 255 to 255. Why is this code not working? ...
4
votes
2answers
289 views

Mathematica list element sort

I have a list, say, ...
18
votes
11answers
1k views

Generating an ordered list of pairs of elements from ordered lists

I have a pair of ordered lists. I want to generate a new ordered list (using the same ordering) of length n by applying a binary operator to pairs of elements, one from each list, along with the index ...
2
votes
2answers
151 views

Comparing elements of the $n^{\text{th}}$ sublist in a ragged list with the $n^{\text{th}}$ member of a sequence

I have a list of lists that are not of the same length (for example, {{6}, {14}, {6, 26, 30}}), but I have to compare every element in the $n^{\text{th}}$ sublist ...
4
votes
1answer
147 views

MapThread with several cells as output

Assume I have defined the following function: FF[{x_, y_}] := {x^2 + y^3, 3.5*x*y} I would like to apply FF on a list of ...
17
votes
8answers
558 views

Applying And to lists of Booleans

I'd like to take {True,True,False} and {True,False,False} and apply And to get ...
1
vote
1answer
104 views

How can I manipulate with elements inside sublists if sublists of different lenght?

I have some kind of output like this: {{1, 5}, {1, 13}, {1, 5, 25}}. I would like to be able to enter in each sublist and make sums of every two elements in sublists, for example my desired output ...
3
votes
2answers
95 views

How to uncompress only the compressed elements in a matrix

I have data in a rectangular structure – something like matrix={{a,b,c},{d,e,f},{g,h,i}}. The problem is that some of the columns consist of uncompressed data and ...
5
votes
6answers
315 views

Creating sums of elements from a list

I have a list $(d_1, d_2, .. d_k)$ and I want to create all sums that I get for adding only two elements for my list $(d_1+d_2, d_1+d_3,...d_{k-1}+d_k)$. The ...
13
votes
7answers
368 views

Get the first element after the first sequence of length N of consecutively increasing values

I'm looking for an efficient way of extracting the first element after the first sequence of N consecutive elements in which the values are increasing. If these are the data of a toy example: ...
7
votes
7answers
427 views

How to pick an element of a row corresponding to the minimum in a particular column?

How can I find what value in column 1 of my list corresponds to the minimum value in column 2?
3
votes
1answer
169 views

Efficiently keeping elements in a list (an input list) that exist in another list (a keep list)

I have some code that generates lists of integers (one such list is called, for example, inputList). I also have a "master list" of integers that should be kept, ...
1
vote
2answers
198 views

How to arrange a list on a triangular pattern?

I've made a multiplication table with this: Then I removed the repeated permutations with: gg = Range[1, 10]; Subsets[gg, {2}] // TableForm Now, when the ...
11
votes
4answers
291 views

Thread a function over a list and with a non-atomic 2nd parameter?

From the documentation, Thread's behavior on functions where the first parameter is a List and the second is an atomic expression, is this: ...
1
vote
2answers
226 views

Symbolically associate vectors and their norms

I am wondering how to handle the following situation: I do have vectors of known dimension that I would like to handle symbolically. I suppose I can do something like ...
11
votes
2answers
1k views

Sorting a list with secondary criterion

Is there an easy way to sort a list on multiple levels of criteria? By this I mean, first the list should be sorted according by criteria A (the same as using the usual sort function, ...
9
votes
5answers
335 views

Finding first instance of a relationship between elements in two lists

Suppose I have two lists, say: A = {1,5,10,200,50,7} B = {4,3,19,78} For each element in A, I would like to find the index of the first element in B which ...
27
votes
12answers
1k views

Map a function across a list conditionally

It seems that this is a really basic question, and I feel that the answer should be obvious to me. However, I am not seeing. Can you please help me? Thanks. Suppose I have a list of data ...
5
votes
5answers
998 views

Replace values which obey certain criteria

I'd like to replace all values in a list which obey one or more criteria with another value. Example: Replace all values>30 by 30. data={{3,35},{2,7}} ...
21
votes
3answers
795 views

Emulating R data frame getters with UpValues

What's the best way to emulate R's data frames functionality? This includes the ability to select rows and columns in a 2-dimensional table by the string identifiers positioned typically in the first ...
2
votes
4answers
359 views

Building a list recursive with one or more arguments

Consider the following: data={a,b,c,d}; res={{a,b,c,d},{b,c,d,e},{c,d,e,f},{d,e,f,g}}; The idea is to define a function ...