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

learn more… | top users | synonyms (3)

2
votes
4answers
235 views

Removing coefficients and repeated elements

I got to a problem where as I just can't find the proper Mathematica command. I'm given a list, for example: $\{1,x1,-x1,x2,x5,x3,-x2,-x4\}$ I need this to become $\{1,x1,x2,x3,x4,x5\}$ The ...
1
vote
1answer
142 views

Value for x such that |(x-y)| is minimum

I have a list Y={y1,y2,y3,...,yn} And I would need to find x such that Abs[x-Y[[i]]] for all $y_i$ in $Y$ is minimum. ...
7
votes
4answers
299 views

Unexpected behavior from GatherBy in version 7

I have come across what appears to be a bug in GatherBy. It appears similar to the problem of using Table[Random[], {1000}] in ...
27
votes
6answers
1k views

How to select minimal subsets?

I am a newbie, so please point me in the right direction if you feel this question has been answered somewhere else before. Here goes: Suppose I have a list like this: ...
17
votes
9answers
1k views

How do you check if there are any equal arguments(even sublist) in a list?

I would like to set up a function which has to return True if at least two arguments of a given List are equal. So if I give {1,4,6,2} to the function it has to ...
3
votes
4answers
232 views

Test whether date is in a certain period

I have one table which contains time periods ("start" and "end") and a "type" for every ...
4
votes
7answers
732 views

Finding the midpoints of an ordered list of numbers

Suppose that I have an ordered list of numbers. The numbers in the list may be evenly spaced, but they may not be. Here are two examples, list1 and ...
1
vote
2answers
104 views

Making two lists which share part of its name, while its name is also an element of the list

I am stalled with the following problem: I want two lists, for example: name={1,2,3} and namec={{1,2,3},{x,y,z},name} The ...
0
votes
1answer
265 views

How can I build a GraphicsGrid of fixed size that rearranges the empty plots?

OK, let's make one final attempt; they say the third time is the lucky one! Following @rm-rf 's suggestions, I will try to be as clear as I can. My Mathematica code reads and plots simultaneously ...
2
votes
2answers
411 views

How can I build a GraphicsGrid of arbitrary size?

This is actually a very simple scenario, in order to make simpler this question Part I. Consider the following piece of Mathematica code ...
8
votes
4answers
445 views

Gather list elements by index

The following list has some elements that are labeled. For example {1, 2} -> 1, {-1, 3} -> 3, etc: ...
5
votes
2answers
184 views

Split a list of pairs at points with decreasing first element

I have a list in which the first index is mostly increasing, but dips sometimes. I need to split this list in two or more lists in this way: when the first element of a pair is smaller than the ...
8
votes
2answers
896 views

Rapidly binning 3D data

I have a set of data (about 20 million datapoints for my real data) of the form {x, y, z, m}. There are 3 spatial coordinates x, ...
14
votes
1answer
233 views

Ordering function with recognition of duplicates

Fairly often I have a need to get the Ordering of an expression but with recognition of duplicates. For example: ...
6
votes
3answers
676 views

Subsets of a list

Consider the following demand of products for the next four months. data={1,20,3,40}; I could produce the whole demand in the first months, leading to the ...
20
votes
7answers
1k views

Elegant and fast way to join all string sequences

I want to do what title says: {"a","b",1,2,3,4,"a",2,2,2,"edg","?"} => {"ab",1,2,3,4,"a",2,2,2,"edg?"} in the most elegant way. For example one replacement rule for ...
6
votes
4answers
322 views

Inserting points along a linear interval between adjacent coordinates in an array

Say I have a list of coordinates in an array {{0, 0}, {0, 1}, {1, 1}} I'd like to create a new array where, between each pair of nearest-neighbor coordinates in ...
10
votes
5answers
442 views

ListPlot under conditions

I have a data file containing several columns and thousands lines of data. Below I present a small portion of it, in order to express my issue: ...
0
votes
1answer
138 views

How to simulate a multivariate recursive system from a list

New to mathematica, trying to use Eric Swanson's Pertubation AIM program to solve DSGE models. His code produces a solution as a list or a table. My question is how do I use this list to simulate the ...
20
votes
2answers
901 views

Data Table Manipulation in Mathematica: Step 2

In this previous post (Data Table Manipulation in Mathematica) we find the brilliant suggestion proposed by Leonid Shifrin that allows to select specific rows identified by the header name. I'm now ...
5
votes
2answers
293 views

Building conditional lists with Manipulate

I'm trying to select elements of a list that satisfy some criteria using Manipulate[]. Given 2 lists: ...
4
votes
1answer
464 views

Using Thread or MapThread over multi-level, ragged lists [duplicate]

This may be a rather strange question. I will try to create a sort of minimal working example. Suppose that I have two lists, list1 and ...
20
votes
5answers
803 views

MapThread over sublists of different length

I have a list which looks like this: l={{1,0,3,4},{0,2},{0,0,1,3},{1,2,0}}. Now I would like to count how many 0s the sublists contain in the first, second,... ...
1
vote
1answer
70 views

List-manipulation Interpolation

For example, I have the following list: AA={{0, 20000.}, {26.6, 19950.}, {53.2, 19950.}, {79.8, 19950.}, {97.1198, 18644.1}, {102.681, 16452.3}} Another ...
2
votes
0answers
65 views

How to create a ListPlot containing two lists? [duplicate]

I'm trying to plot a set of points where one list corresponds to the X values another list corresponds to the Y values. I have ...
13
votes
6answers
592 views

Sort+Union on a list

Probably this is too trivial question for this forum but for some reason I am not getting it on my Mathematica 7 so far. I have a list ...
3
votes
3answers
193 views

Renaming a list with name obtained interactively

I have a list say: m = {1, 2, 3} The list is inside a package, and is the result of a calculation. I want to give the user the option to rename it, for example ...
1
vote
1answer
192 views

Averaging multiple 2D data sets

I have multiple data sets, each of which is a 2D matrix. I want to construct a new 2D Matrix in which each element is the average of that element for all the original data sets. i.e ...
-5
votes
1answer
300 views

Split dataset based on the first column [duplicate]

I have a dataset which I want to split based on the first column. The data looks like this ...
9
votes
8answers
589 views

Adding elements to a collection of lists

I would like to add element a at the start of a series of lists. For example I have a collection of lists called ...
7
votes
4answers
557 views

Prepend 0 to sublists

My question is similar to this one, but my goal is to prepend a single 0 the each sublist, not incrementally many 0's. The file I'm working is a CSV containing around 50K sublists of length 35. I've ...
1
vote
1answer
171 views

Extracting values

I have imported a data from an excel sheet. I want to extract parts of the list based on some conditions. First I want to create one list whit the The Coca-Cola ...
2
votes
2answers
108 views

Automatically generated summation region

In a multiple Sum I need to put an automatically generated summation region. But when I generate the summation region automatically I get a list whose elements are ...
8
votes
3answers
552 views

Creating a simple function to compute the average of the difference between pairs of elements in an array

I have a list of the form: {{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}, {{9, 10}, {11, 12}}} How can I create a function which will take each set at the highest level of ...
-5
votes
5answers
535 views

Translating MATLAB's cell2mat into Mathematica

How I can define a function in Mathematica such that it acts same as the cell2mat command in MATLAB? Example (in MATLAB): ...
6
votes
5answers
219 views

Multiple level lists

Let there be a list, Sample={{{1, 2, 3}, {a, b, c}}, {{2, 3, 4}, {d, f, g}}} I want to go to individual sublists and do some operation on it.I tried a few things ...
6
votes
1answer
537 views

Find all permutations with reversals / cyclic permutations removed

I have a list of all non-cyclic permutations of n labels. How can I get rid of all elements which are redundant in the sense that they are the inverse of another one. For instance if n=4, the ...
3
votes
2answers
115 views
3
votes
1answer
626 views

A rotation-like transform on a matrix

Do not be confused with comments, those are for previous version of the question - Kuba Imagine I have a matrix of the form: ...
5
votes
2answers
234 views
7
votes
2answers
318 views

Intersection for lists of numeric data

I know that Intersection is a pattern matching function and will not evaluate list elements to determine if two or more list have equal elements. So my question is, ...
5
votes
4answers
239 views

Picking numbers within a list with an interval of 60

I have a list of integers from 1 - 400. I choose n random numbers with replacement from the list. Here is an example: ...
7
votes
5answers
646 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 + ...
9
votes
5answers
448 views

Span a function across several consecutive elements in a list

Suppose that I have a list called list. I would like to span an arbitrary function f across specified consecutive elements in ...
0
votes
2answers
136 views

Create a Matrix out of two matrices

I have two matrices A = {{a1,a2},{b1,b2}} and B = {{x1,x2},{y1,y2}}. I would like to create out of these matrices a new matrix ...
10
votes
6answers
332 views

Using MapIndexed only at certain elements of a list

MapIndexed is a very handy built-in function. Suppose that I have the following list, called list: ...
0
votes
0answers
46 views

List elements and iterator name collision [duplicate]

Let there be two lists, exp = {{i, i}, {j, j}}; exp2 = {{r, r}, {o, o}}; and there are two Table commands to access them. Then, ...
2
votes
1answer
99 views

Map and Scan ignore HoldFirst

I am trying to write a simple function that takes a list of data and outputs it to a file. I'd like the name of the file to be the same as the variable that holds the list. It seems that giving a ...
2
votes
2answers
196 views

Replacing all values in a table > $T$ [duplicate]

I want to generate a table of Euclidean distances from the points in a list to a given point, e.g.: ...