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

learn more… | top users | synonyms (3)

15
votes
3answers
272 views

Undocumented form for `Extract`

Prompted by a comments conversation here, here's an interesting (and often performance enhancing) use of Extract: ...
0
votes
0answers
20 views

How do I plus these values in a list [duplicate]

Hi I need to plus 3 values together each time for the rest of the list. How do I basically add the 3 sets of values together each time. When I try Plus[] it returns the same input values back to me ...
0
votes
1answer
67 views

A problem with set values

The following code is just an example to clearly explain my problem. Assume that : ...
1
vote
1answer
147 views

Compile with array operations

When I use the function f with only the Module ...
0
votes
0answers
29 views

Splitting a list into list of lists [on hold]

I am trying to split a flattened list of data into a list containing 4-vectors. Consider the sample set of data (number of elements always a multiple of 4) ...
0
votes
0answers
36 views

A problem with functions and Infinite expression 1/0 encountering

Following code (function) makes integrals and then replace f[x] with Cos functions and calculate the definite parametric ...
6
votes
2answers
168 views

Map structure of irregular list, Flatten then reconstruct list using structure

I'm trying to use Compile[] to improve the performance of an algorithm. The algorithm works on a set of matrices which are not of a similar shape. Unfortunately ...
3
votes
4answers
118 views

Randomly selecting and reinserting a subset of elements in a list

This question is similar to my other question: How do I randomly select 'k' positions in a list and shuffle their respective elements without effecting the other elements? Imagine first a ...
9
votes
2answers
398 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
1answer
44 views

Sorting a table of vectors with weights [duplicate]

I'm trying to simplify a table, for instance {{1, {4, 2, 0}}, {4, {2, 4, 0}}, {-2, {3, 3, 0}}, {1, {3, 0, 3}}, {-3, {0, 4, 2}}} Here the first column is the ...
49
votes
7answers
9k views

Elegant operations on matrix rows and columns

Question The Mathematica tutorial has a section 'Basic Matrix Operations', describing operations like transpose, inverse and determinant. These operations all work on entire matrices. I am missing a ...
9
votes
4answers
380 views

Permutations[Range[12]] produces an error instead of a list

This input: Permutations[Range[12]] Results in this (error) output: ...
3
votes
4answers
241 views

Find the longest constant sublist

Given a list list = {1,2,2,2,2,5,1,3,2,6,6,6,6,6,6,6,6,6,6,6,10,-3}; how to find the longest constant sublist (or equivalently the element and the number of ...
1
vote
1answer
27 views

How to set the values into some variables from different lists [on hold]

I have a list of Values and a list of variables. I want to set the Values into Variables. Assume the following code: ...
4
votes
1answer
99 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 ...
2
votes
1answer
68 views

MathLink c++ passing lists of real values simple example

So this may come down to me not being a very competent programmer but I am struggling with passing list from Mathematica via MathLink that aren't of integers. The final code I am hoping to get out of ...
1
vote
1answer
64 views

Sectional averages of a list [on hold]

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) ...
1
vote
1answer
48 views

Generating a random sample of elements from a list that includes a subset of the list

Imagine I have a list: tList = {item1,item2,item3,item4,item5,item6,...}, and I'd like to take a random sample of numItems ...
4
votes
4answers
274 views
0
votes
2answers
91 views

How to partition three years of data into daily samples

I'm trying to find mean of temperature data list. The temperature data list has 3 hours steps which means I have 365*8=2920 temperature measurements per year. My data are temperatures of 13 years. ...
0
votes
1answer
94 views

I don't understand ListCorrelate! [closed]

I want to solve a PDE equation (like Schrodinger equation) using finite difference in Mathematica. I don't understand what this code does! ...
2
votes
1answer
98 views

Convert frequency counts to long notation in Mathematica

I have a series of frequencies of values, e.g. 5 times 1, 10 times 2 and 5 times 3, as in list={{1,5},{2,10},{3,5}} and I would like to convert this to long ...
8
votes
3answers
356 views

What is the most efficient way to map a linked list?

In order to work with lists effectively using common recursive patterns from functional programming, it's often most convenient to worked with the "linked list" representation, that looks like this: ...
0
votes
1answer
61 views

Creating If statements programmatically [duplicate]

I want to write an algorithm that returns a sequence of numbers, starting from a specified point but stopping once a criterion has been reached. For example ...
2
votes
3answers
135 views

Wrapping a data selection in Mathematica

I was wondering what would be the most efficient way to add brackets to given elements in my data set in order to change it's form from {{a,b},{c,d}} to {{{a},b},{{c},d}}. I took a look through a few ...
0
votes
2answers
104 views

Summarizing SQL Tables

data = Table[SQLSelect[conn, "All", {"col1", "col2"}, SQLColumn["col1"] == n && SQLColumn["col2"] == o], {n, 1, 8}, {o, 21, 30}]; This results in ...
24
votes
4answers
1k views

How to efficiently find positions of duplicates?

Is there an efficient way to find the positions of the duplicates in a list? I would like the positions grouped according to duplicated elements. For instance, given ...
3
votes
5answers
145 views

Summarize a list of pairs / (Using GatherBy and Tally?)

Given a list of (frencuently repeated and unsorted) pairs {Mode, SubMode} I want to form the list ...
3
votes
1answer
145 views

Converting truth tables to boolean expressions

I have a truth table for a Boolean expression represented like this ...
0
votes
3answers
84 views

How to solve correctly inside a DO loop and then plot

Here is the corresponding code First the equations setup ...
0
votes
1answer
29 views

how to use Manipulate changing the values of a List?

How can I "change" the values in the list h={2,4,6} using Manipulate? (Next line was edited after hte first Alexi´s comment) I WANT to choose real values in h[[1]], h[[3]] , h[[3]] between 0 and 8. ...
1
vote
2answers
286 views

Research positions of lists of varying size

I'm new to the site and I am French, so I ask your indulgence for my future mistakes in English. I would like to optimise the following code : ...
0
votes
1answer
84 views

confusion about the use of MapThread and out product

To help distinguish the various dimensions, I have a model which outputs a vector in a series of time intervals, I then construct a list of these models. Next, I would like to compute the outer ...
2
votes
1answer
61 views

Using Total on a list supplied by a rule

I'm confused as to why Total complains about a nonatomic expression here: ...
2
votes
2answers
240 views

Covariance of a P x M x N matrix

I have a stack of tiff files. When imported to Mathematica, they form a $P \times M \times N$ matrix, where $P$ is the number of single images in the stack, $M$ is the number of horizontal pixels and ...
1
vote
3answers
84 views

Creating Graph with two or more values in second column

For a social network analysis I have two columns. The second column has one, two or more values. Something like this: ...
0
votes
0answers
38 views

Why this error Deleting an element in a list? [closed]

This code efining a funcion in a code gives me an error: Neigh[k_] = Delete[Table[i, {i, 1, 24}], k] The error is... Delete::psl: "Position specification k in ...
1
vote
1answer
66 views

Need help defining my own rounding function

First of all: I'm a beginner with Mathematica. I'd like to define a function called Rounding which does the following: if for $x = n+a, n \in \mathbb{N}, a\in ...
1
vote
1answer
46 views

Selecting items in a list based on multiple tests

I have an array of strings that look like this: ...
1
vote
1answer
40 views

Finding the position in a list where the maximum or minimum value occurs [duplicate]

We can use Max[exampleList] or Min[exampleList] to find the maxima and minima of ...
1
vote
0answers
65 views

List comprehensions pythonic way [closed]

I am trying to avoid of using the indexes for list manipulations as these usually gives me headaches. In Python there are wonderful way: ...
0
votes
0answers
80 views

Nested for loop in mathematica

I have a code in mathematica with a loop which iterates over a variable i and calculates a list of numbers h given the start parameter f: ...
1
vote
1answer
32 views

Padding sub-lists in a list [closed]

I have a list, say `Alist`` Alist = {{1}, {2}, {1, 3}, {4, 5, 6}, {4}}; and want a list, Blist such that ...
0
votes
1answer
104 views

How to format the data in a table to have only numbers

This question is in continuation of my earlier query, how to store output of a function in a table for future use. I am able to store the output of my function in a table, however the table consists ...
3
votes
1answer
70 views

Select row from a table by column value

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, ...
1
vote
2answers
124 views

MapThread with List Manupulation

I have the following three lists: ...
2
votes
1answer
79 views

Restoring the 1-to-1 correspondence between elements in two lists, where one list is used as a guide to prune elements from the other

when we wish to use one list to select items from another using something like Pick, writing the following code, for example, causes us to lose the 1-to-1 ...
2
votes
2answers
255 views

Index-based Array splitting

I have an array of arbitrary elements, say strings: testArray = {"String A", "String B", "String C", "String D", "String E"}; How can I split this into two ...
3
votes
1answer
121 views

Social Network Analysis - Get the End Points of an Edge

I want to get the end points of an Edge of a Graph. For example see the following source, ...