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

learn more… | top users | synonyms (3)

2
votes
2answers
329 views

How can I transform a list of binary digits into integers?

I want to transform a list of binary digits into integers. With the Table function, I produce four lists of binary digits of length 32. Then I tried to turn these ...
1
vote
1answer
134 views

How can I make my code simpler?

I want to find similar letters ...
7
votes
3answers
313 views

Find all the last weekends in a year

In order to obtain the weekends of a year you'd use something like this: ...
15
votes
7answers
727 views

Removing elements from a list which appear in another list

There are two lists {a, b, c, a, d, a, e} and {a, c, a}. I need to remove those elements from the first list which appears in a second list, to get {b, d, a, e}
2
votes
1answer
128 views

Error in setting matrix elements [duplicate]

Possible Duplicate: How to Set parts of indexed lists? For better organization of my code, sometime I use data objects in the form: ...
5
votes
3answers
354 views

Efficiently extracting an array subset given a separate array

I have two arrays. The first array consists of tens of millions of rows and three columns with a string, a number, and a string. ...
7
votes
3answers
620 views

How can I get a running sum for a list?

I've got following data I'm reading from a file: ...
6
votes
3answers
861 views

Ways to compute inner products of tensors

One way to evaluate the following sums is combining Table and Sum: $u_{abcd} = \sum_{e=1}^3 v_{aeb}w_{ced}$ $q_{ab} = \sum_{d,e=1}^3 v_{d e a}w_{deb}$ It will look like ...
4
votes
2answers
399 views

How find the first element of a list greater than zero (or another criterion) when there is a symbol in the list?

I need to find the position of the first element of a list that is either greater than zero (or some other criterion) or a symbol. Something like ...
17
votes
3answers
643 views

Optimising 2D binning code

I have a set of (x,y,z) data, 45,000 to be precise and I want to bin the z values in 256 equidistant bins based on their (x,y) values. The final array should be a set of 256x256 array with each slot ...
6
votes
5answers
321 views

Handling holidays in financial time series

I have two lists: list1and list2, which are financial time series with only 2 variables—date and price. The problem is: these ...
5
votes
2answers
264 views

Concatenate strings from different levels of list

After a lot of trouble I've finally come pretty close to what I want to do. I now have a list that looks like this: ...
0
votes
0answers
49 views

How to ContourPlot a Table? [duplicate]

Possible Duplicate: Why is ContourPlot not displaying this curve? Why do I have to put Evaluate[] here I'm trying to plot certain contours of a function $f:\mathbb R^2\to\mathbb R$. What I ...
1
vote
1answer
212 views

System Identification with large Input/Output Data

I have some questions about system identification. I made some measurement of current step (input) and voltage response(output) and I want to fine the parameters of my impedance. The sample rate is ...
4
votes
1answer
131 views

RecurrenceTable with vector

Mathematica can do a RecurrenceTable with a vector, here is a simple example: RecurrenceTable[{x[n + 1] == 2* x[n], x[0] == {1, 2, 3}}, x, {n, 3}] with output ...
1
vote
3answers
470 views

Ignore missing data while doing a Mean

I want to compute the mean of a list while ignoring missing values, but I don't find a lot of information on how to deal with Missing data in Mathematica. I have a list like : ...
2
votes
2answers
157 views

Modify a sub-part of a sub-list only

I have this list: a = {{{0, 0}, {1, 7}, {2, 0}, {3, 2}, {4, 7}}, {{0, 0}, {1, 0}, {2, 1}, {3, 2}, {4, 7}}} and I'd like to transform it to this: ...
5
votes
5answers
418 views

Elementwise join

I have two tensors of arbitrary but equal rank n (and equal dimensions): A and B, and I want to get a third tensor of rank n + ...
6
votes
1answer
132 views

Implementing Remainder Tree

I want to implement Remainder Tree based on this. With the answers on SE I've come up with: ...
14
votes
9answers
480 views

Distributing elements across a list of lists

I have two lists: u = {{1, 3}, {2, 6}, {3, 9}} v = {0, 4} and I want to obtain this list from them: ...
3
votes
2answers
106 views

Nested List Product

I want to apply Times on the elements of a list such that: ...
5
votes
1answer
171 views

How I can use Apply or Map with If?

I have list of objects: list = {{1, 1, 0.05, 0.05}, {2, 2, 0.05, 0.05}, {13, 13, 0.05, 0.05}}; list = {{x,y,Vx,Vy},{x,y,Vx,Vy},...}; And ...
1
vote
2answers
222 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 ...
5
votes
2answers
525 views

How can I get every distinct size-n combination of a list?

Let's say I have a list: {a, b, c} I would like to, for say $n=2$ get every distinct pair from that list. That is, the expected result should be, for some ...
1
vote
1answer
99 views

How do I define a function that, when given a list of parameters, plots a family of functions?

So far I've got this: draw[a_, b_] := Plot[{f[a, b[[1]], x], f[a, b[[2]], x]}, {x, 0, 5}] The function draw will be used like ...
5
votes
4answers
478 views

Join lists in a list of lists

What's the best way to join two consecutive lists in a list of lists ? For example if I have the list x = {{1}, {2}, {3}, {4}} and I want to get in x ...
2
votes
2answers
150 views

How can I replace part of list and have the replacement affect the initial list?

I have a list: list = {{1,1,0.05,0.05}, {2,2,0.05,0.05}}; and I want to do this change ...
1
vote
1answer
157 views

Random sample with gap sizes

Lets say I have 101 instances of data with multiple attributes. In particular case, one attribute has 7 unique values. I want to get ...
1
vote
2answers
264 views

How to generate patterns by a list of integers

I have a list of integers {3,4,2,2}. This list will give patterns {x_,_,y_,y_,_,_,z_,z_,w_,w_,x_} and ...
9
votes
2answers
430 views

How to represent a list as a cycle

I want to select distinct cycles (represented by List). The cycle {a, b, c, d} must be the same as {b, c, d, a} or ...
0
votes
2answers
139 views

How can I assign some part of data from one list to another list?

I don't know this is correct question or not,but I have a doubt. I have two Lists names are list1 and ...
18
votes
1answer
453 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 ...
7
votes
4answers
482 views

Using MapThread on list of lists

Just a light weight question for learning. If you think this was asked before, please feel free to close it. I am trying to learn MapThread more, and wanted to use ...
8
votes
5answers
304 views

How can I find these patterns' signatures?

I think I can explain it best starting with an example. I have the following lists: ...
5
votes
3answers
167 views

All values for a function with two arguments without Outer

Given two lists $l_a = \{a_1, a_2, a_3\}$, $l_b = \{b_1, b_2, b_3, b_4\}$ and some function $f$ accepting two arguments, how can I produce a list of all values $f(a, b)$ for $a\in l_a$ and $b \in l_b$ ...
8
votes
1answer
183 views

Transformation rule on a list of non-negative integers

I am trying to create a transformation rule that takes a list of non-negative integer values of any length, finds a non-zero entry in the list, adds 1 to all preceding numbers, subtracts 1 from the ...
2
votes
1answer
480 views

If-statement does not evaluate if condition is true [duplicate]

Possible Duplicate: How to avoid returning a Null if there is no “else” condition in an If contruct I know there are other ways to solve this problem. Just because I'm curious I tried: ...
7
votes
6answers
327 views

The locations of (row-wise) minimum elements in a list

I have a list representing a 2D matrix, such as this 3 ⨉ 2 one: {{2.1, 1.01}, {0.01, 7.2}, {7.8, 2.0}} Does anyone know how to find the minimum of each row, ...
2
votes
1answer
2k views

Filtering Lists in Mathematica [duplicate]

Possible Duplicate: Select/Delete with Sublist elements? I need help in filtering long lists of x,y coordinates.Lets use the following list as an ...
2
votes
2answers
482 views

Making NIntegrate behave like a listable function

I have a function defined by $$f(t)=\int\limits_0^t g(x) dx$$ $g(x)$ is a complicated function (specifically the Mittag-Leffler function which has recently been implemented in Mathematica 9 as ...
10
votes
1answer
199 views

Unexpected result from Flatten

Consider the following three evaluations involving Flatten: Flatten[f[f[f[x, y], 1, 2], f[x, y]], Infinity, f] f[x, y, 1, ...
11
votes
8answers
453 views

Any built-in function to generate successive sublists from a list?

Given lst = {a, b, c, d} I'd like to generate {{a}, {a, b}, {a, b, c}, {a, b, c, d}} but using built-in functions only, ...
1
vote
4answers
332 views

Combining two lists [duplicate]

Possible Duplicate: How do I obtain an intersection of two or more list of lists conditioned on the first element of each sub-list? I would like to combine two lists. ...
6
votes
4answers
255 views

How to sum over duplicates?

I have a list of the form: {{1, 0, 1}, {2, 1, 2}, {1, 0, 3}, {2, 4, 2}, {2, 1, -1}, {1, 0 ,0}} that I would like to sort such that I calculate the sum over the ...
18
votes
7answers
543 views

How do I obtain an intersection of two or more list of lists conditioned on the first element of each sub-list?

Given two lists like list1 = {{1, 1}, {2, 4}, {3, 9}, {4, 16}}; list2 = {{2, 6}, {3, 9}, {4, 12}, {5, 15}}; I would like to produce an output like ...
9
votes
2answers
258 views

How to partition a list and leave in the last sublist which is of different length? [duplicate]

How to partition a list and leave in the last sublist which is of different length? In[75]:= Partition[{1,2,3,4,5},2] Out[75]= {{1,2},{3,4}} I want it to be ...
4
votes
6answers
207 views

Filter list with different list in it

I have a list like: {{{4, 14}, 1}, {{4, 15}, 1}, {{4, 16}, 1}, {{4, 17}, 1}, {{4, 18}, 1}, {{4, 14}, 3}, {4,15}, {{4, 16}, 2},{4,18}} Now I want to ...
3
votes
2answers
164 views

Subscript and Part: What's going on in this example?

Example I came across the following simple example from A Beginner's Guide to Mathematica, by McMahon and Topa, which I believe was written circa version 5.2. (FWIW, I'm using v9.) ...
2
votes
1answer
389 views

RowReduce: Solving for the resource vector (a, b, c) in Augmented Matrix

Here are two examples: RowReduce[{{3, 1, a}, {2, 1, b}}] evaluates to {{1, 0, a - b}, {0, 1, -2 a + 3 b}} but ...
1
vote
3answers
1k views

How to create functions of arbitrary number of variables? [duplicate]

In the following code what would be the simplest way to generalize it to say some $N_f$ number of $z$ instead of just $z_1$ and $z_2$? ...