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

learn more… | top users | synonyms (3)

5
votes
1answer
411 views

Numbering element in descending order

How can I numbering the elements in descending order of second elements of sublists? For example, if I have the list which is ...
5
votes
6answers
327 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 ...
4
votes
1answer
92 views

Parsing string with nested information

I am trying to parse a string, but I have no idea how to solve the following problem ...
4
votes
2answers
75 views

How to keep first observation and delete other observations of each group in unbalanced Panel data

I have a huge panel data. I want to create a new data keeping only first observation of each group. How can I achieve it? For illustrative purpose; ...
4
votes
3answers
131 views

Extracting columns from multidimensional list

Perhaps a very easy question but I posted this on the Wolfram Community and didn't get any answer.. Suppose I have data like: ...
4
votes
2answers
135 views

Sorting out atom types in an XYZ file

I am trying to rewrite the output of "VertexCoordinates" such that instead of a hybrid list of atoms and coordinates that result from using the following input program, I want all coordinates of the ...
4
votes
3answers
260 views

How can I change a list to a sequence without destroying nested list

I defined a function f like f[x___, y_] := something; and if xs and ...
4
votes
2answers
551 views

What is the Mathematica way of joining two tables?

Is there a special Mathematica way of joining tables of data together, so that I would get similar functionality as if I was running a database with sql? For example, I have one particular table ...
4
votes
1answer
169 views

How do I randomly select 'k' positions in a list and shuffle their respective elements without effecting the other elements?

Imagine I have some list: listA = {"a","b","c","d","e","f","g","h","i","j"}; I'd like to randomly select k positions in the ...
4
votes
3answers
488 views

Finding elements from a sparse matrix

I am dealing sparse matrices of very large dimensions. I need to locate the positive and negative elements of the matrices and make lists of their corresponding positions. Of course I can write a ...
4
votes
2answers
124 views

How to constrain the generation of all possible orderings?

Here is code from Simon Woods' answer for getting all possible weak (equal ranks allowed) orderings for $N=3$ objects: ...
4
votes
1answer
128 views

Timing Total crashes kernel

Here is a simple test function test[n_] := Module[{i = 0}, Total[Nest[{++i, #}&, {0}, n], -1]] On my system V9.0.1 running OS X 10.6.8 and with a clean ...
4
votes
1answer
173 views

List manipulation - various

Update OK, Please forgive the messiness of this, but I am working with something like: ...
4
votes
7answers
680 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 ...
4
votes
2answers
487 views

Removing not-a-number entries from an array of numbers

I have a list of {x, y, z} coordinates from a wavefront sensor I'm working with. However, not all of the imported points have actual values, but they still get ...
4
votes
1answer
373 views

Create a table with inline conditions

I am trying to create a table with conditionals inline. For example, I'd like to create a 2 dimensional table like this: ...
4
votes
3answers
385 views

Preparing data for making an ErrorListPlot

I often have the following notebook in Mathematica, which I use to make a dataset and associated errors: ...
4
votes
2answers
268 views

Partition a set into $k$ non-empty subsets

The Stirling number of the second kind is the number of ways to partition a set of $n$ objects into $k$ non-empty subsets. In Mathematica, this is implemented as ...
4
votes
1answer
277 views

Use single ListPlot for multiple sets of data (on separate graphs)

This is the code I have working for a single set of data. Is there a way I can structure this to have multiple sets of data? ...
4
votes
2answers
1k views

Converting numbers to integers

I've read the available documentation but I still haven't found an NumberForm -> Integer function yet. No result in this site's search, either. Does it exist? ...
4
votes
3answers
1k views

How to replace all occurrences of an element in a list?

Consider the following: list={1,2,2,2,3}; I would like to replace all 2 with the string "Test". ...
4
votes
1answer
600 views

How do I treat elements in a list as variables inside a module?

I want to be able to assign values to a list element inside a module. For example if I have: ...
3
votes
1answer
131 views

Functional programming approach to avoid traditional loops

I'm currently learning from the wonderful post: Where can I find examples of good Mathematica programming practice? And i'm correcting my habits using Nest/Map/Thread instead of loops. The problem ...
3
votes
3answers
186 views

Pare down list recursively

What is the best way to pare down a list whereby the $n$th number is removed from the list recursively? This ...
3
votes
2answers
250 views

Weird behavior when changing parts of matrix

I have this matrix: mat = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20}, {21, 22, 23, 24, 25}}; and here are its second row ...
3
votes
5answers
228 views

Take the next element in a nested list

My problem is the following: Consider a list of elements. To better understanding my following explanations, I would take this example: ...
3
votes
1answer
123 views

Sectional averages of a list

I am working in Mathematica. I have a table of 200 elements. I want to calculate the mean value for the first 20 elements, for the second 20 elements and so on, up to 200. I will get a table (matrix) ...
3
votes
2answers
633 views

How can I scale the y axis?

I have a file I import and read into a table of $2 \times n$. I can plot this data using the following code: ...
3
votes
2answers
141 views

Change all values of a series to positive values

I would like to change all values of a series to positive values. I refer to my previous question, answered in the most part, very elegantly by RunnyKine. However, there remains a slight glitch that ...
3
votes
2answers
157 views

Using list elements in TrackedSymbols for Dynamic

During the execution of the following code a column of three lists and two sliders are displaying in output. The first list updates if either a or b changes. The second list updates only if the value ...
3
votes
0answers
67 views

Listing all combinations produced by picking one element from each of several sets [duplicate]

I have a problem like this, I am given the following sets {a,b,c}, {d,e,f}, {h,i,j}. I want to pick one element from each set, and output a list of all the ...
3
votes
2answers
106 views

Linear interpolation of a list between periodic anchorpoints

I have a list of the form: list = {1,1,1,2,2,2,3,3,3,4,4,4,7,7,7,19,19,19}; Where we can see that there are an ordered set of integer values that repeat ...
3
votes
1answer
558 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: ...
3
votes
1answer
145 views

Combining the items with common available dates from two lists [duplicate]

I have two lists of data including dates such as data1 = {{{yy, mm, dd}, a}, ...} data2 = {{{yy, mm, dd}, A}, ...} There are some missing dates from each list, ...
3
votes
1answer
158 views

Little problem with Through

list = Partition[Range[20], 5, 5, 1, {}] {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20}} ...
3
votes
1answer
233 views

Equating two lists, element by element

Say you have two lists: listA = {a, b, c} listB = {d, e, f} How would you produce a listC that equates each of the two's ...
3
votes
1answer
210 views

Generating a list of all factorizations

What is the best way to generate a list of all factorizations of some number $n$? I'm quite new to Mathematica so this might be obvious. I have been trying some basic stuff with ...
3
votes
1answer
214 views

Indexing of Large Autonomous System of Equations for Use in NDSolve

I currently have a list of ~150 autonomous ODE's that I need to be able to work with using NDSolve. Fortunately I already have them formatted in plaintext, which ...
3
votes
1answer
273 views

Replace elements in a list

Suppose that I have a list: ...
3
votes
1answer
216 views

Efficiently finding the maximum value of a column in a matrix

Imagine I have a matrix of the following form: TestArray = $((a_1,b_1,...),(a_2,b_2,...),(a_3,b_3,...),...)$, where a specific example might be: TestArray = ...
3
votes
1answer
477 views

Exporting/Importing a Table of complex numbers

I'm generating a long table of list of the form: PN={{1,2,1+i},{3.5,2.6,2}...},{...},... Using: Export["PN.dat", PN, "Table"] ...
3
votes
3answers
434 views

How to pull scalars out of a function that should act on lists?

Suppose I have A = a vecA B = b vecB where a and b are supposed to be arbitrary scalars ...
3
votes
1answer
243 views

How to partition MatrixPlot graphics?

Is there an easy approach - hopefully built-in - to partitioning MatrixPlot graphics into rows or columns (or both) of graphics sharing the same underlying options? ...
2
votes
3answers
88 views

Delete rows based on specific periods

I have data (.xlsx format): two columns - data in first column imported as DateObject (dates with specific time), data in second column are numbers (113388.28, 865165.98 etc.). I want to delete the ...
2
votes
2answers
82 views

Dynamic arrays and lists with compile (Append, Linked lists etc.)

I have a code that I need to compile. The code contains a loop in which I need to gather data into a list. The question is how to best gather data so that the code works inside Compile. The following ...
2
votes
2answers
89 views

Insert at specific resulting positions in multidimensional list?

I have an initial "multidimensional" list (that is, a list that is not a vector): list0 = {{1},{2,3,4},{3,4},{5}}; and I want to insert elements ...
2
votes
3answers
71 views

How to get an element of a list , which is computed out of substituted variables?

What is the best way to get the element of a list, which is computed out of substituded variables? For example one wants to get the first element of the first row of ...
2
votes
2answers
240 views

Generating complete lists of polynomials

I would like to generate a list of all $3$-variable Laurent polynomials with non-negative integer coefficients using a looping construct so that I can, one-by-one, check them for specific ...
2
votes
3answers
238 views

appending element to sub list [duplicate]

I have a list of the form: lstA = { { {"a","b"}, -1.5}, { {"c","d"}, -2 } } I wanto to add another value to each sublist that ...