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

learn more… | top users | synonyms (3)

1
vote
0answers
80 views

What is the efficient way to code Successive Over-relaxation (SOR) method in Mathematica?

I have written a SOR method (SOR is this method) code using C-style procedural loops. However, I think there might be (much) better ways to achieve the same end in Mma avoiding these loops. So my ...
14
votes
8answers
488 views

How to neatly get the sum of symmetric elements in a list?

The task is to compute symmSum[{a, b, c, d, e, f}] (*==> {a+f, b+e, c+d} *) symmSum[{a, b, c, d, e}] (*==> {a+e, b+d, c} *) My clumsy solution is ...
5
votes
1answer
94 views

Path construction using `Nearest` shows ill behavior?

I have a dataSet that I'm trying to sort choosing a starting point and going to its nearest neighbor, and then to its nearest neighbor and so on. To do so, I've ...
0
votes
0answers
36 views

A way to force the code to use all cores [on hold]

I know that if Parallel commands are used , there will be a chance to use all cores. In spite of using Parallel items like ...
1
vote
2answers
26 views

List operation on specific elements [duplicate]

Let's consider two tables given by T1 = Table[{i,j,f1[i,j]},{i,0,2},{j,0,3}]; T2 = Table[{i,j,f2[i,j]},{i,0,2},{j,0,3}]; The functions ...
0
votes
0answers
28 views

NestList…I don't understand how to apply the NestList command properly [on hold]

I am very, very new to Mathematica and am having some trouble with a homework assignment... So, we set up the function f(x)=Rx(1-x) with R=2. Then, we plug in x=0.2 to obtain the value of 0.32. ...
3
votes
1answer
125 views

Apply color function to matrix plot

I want to apply the following color rules to a large table of numbers. I have extracted a part of the table to use as an example. I would like to assign 5 different colors to 5 different ranges of ...
1
vote
1answer
46 views

Simple subtraction question [duplicate]

I have two lists. a = {{2, 2}, {3, 3}, {4, 4}, {5, 5}}; b = {1, 1}; I want to subtract a from ...
2
votes
2answers
46 views

Ordered indices of a multiple product or sum

Given a summation like $$\sum_{1 \leq i_1 < i_2 < \dotsc < i_k \leq n} f(i_1, i_2, \dotsc , i_k)$$ how can the lists of indices be enumerated? For example, if $n=4$ then the possible lists ...
2
votes
0answers
31 views

What is “ (Dialog) Input [ ] := ” after evaluating a cell?

I have done a time-consuming run and calculation. After many hours ( about 7 hours!), the black color which shows that the cell is evaluating, turn into gray and a strange text appears like this : ...
-1
votes
0answers
27 views

Manipulate curve together with data list [on hold]

I have a function with two parameters that I want to play with by using "Manipulate[]". And a list of data that i would like to plot together with the function and see them under "Manipulate output ...
14
votes
7answers
587 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}
8
votes
0answers
108 views

Strategies to find curves on messy data using FindCurvePath

I have a set of data points that correspond to roots of a transcendental equation with respect to a parameter (the abscissa) which, by the properties of the system, define continuous curves (might be ...
3
votes
5answers
134 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 ...
0
votes
2answers
77 views

How to generate a list with a loop, and put it into a variable?

I am pretty new to Mathematica and to coding in general. I want to do a very specific thing, but I unable to do it. Please explain in detail how I can make this work. Here's the details on what I am ...
10
votes
2answers
239 views

Select cases from a list

I have a list in the form : {1,1,1,0,-1,-1,1,1,1,0,0,0,0,-1,-1} No I'm trying to select only those sequences which start with 1 have a zero (or many zeros) ...
0
votes
1answer
66 views

Matrix Operation

I have a $3\times3$ matrix A, and a function sTrans that outputs two $3\times3$ matrices in a list when given a $3\times3$ ...
2
votes
2answers
180 views

How to select the first “lowest” (first valley) number in a list?

I would to select the first valley of the list of coordinates below. It should be {3, 1}. ...
0
votes
1answer
47 views

How to test if any set of pairs contains elements of other list? no matter order of elements

I want to detect if a set of pairs, for example a={{2,5},{6,3},{1,4},{8,7}} contains a given pair, for example tabu={{4,1},{2,6}} but don´t be relevant the order inside pair (pair {i,j} is equal to ...
0
votes
0answers
27 views

How to switch elements i,j in a list? [duplicate]

Are there any direct function to switch elements i,j in any list? or is necessary to create one with Do / If ? (I don´t ask for making me this function if it doesn´t exists) My target is can ...
19
votes
3answers
362 views

Undocumented form for Extract

Prompted by a comments conversation here, here's an interesting (and often performance enhancing) use of Extract: ...
6
votes
3answers
205 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 ...
0
votes
0answers
21 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
76 views

A problem with set values

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

Compile with array operations

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

Splitting a list into list of lists [closed]

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
38 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 ...
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
49 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
386 views

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

This input: Permutations[Range[12]] Results in this (error) output: ...
3
votes
4answers
248 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
29 views

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

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
108 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
78 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 [closed]

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
52 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
276 views
0
votes
2answers
96 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
98 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 ...
9
votes
3answers
382 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
139 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
150 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
158 views

Converting truth tables to boolean expressions

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

How to solve correctly inside a DO loop and then plot

Here is the corresponding code First the equations setup ...
0
votes
1answer
31 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. ...