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

learn more… | top users | synonyms (3)

1
vote
1answer
64 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
57 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
48 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
vote
2answers
134 views

How can I create a list containing the normalized element-by-element product of two given lists?

I have to calculate: How can I create such a sum? Do I have to set the factors of each term manually (one by one), like G1 = 1, H1 = 1, G2 2, H2 = ....? ...
0
votes
2answers
83 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
287 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) ...
2
votes
2answers
198 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
74 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$ ...
8
votes
0answers
130 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 ...
0
votes
1answer
50 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 ...
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 ...
22
votes
3answers
471 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
81 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 ...
0
votes
1answer
104 views

A problem with set values

The following code is just an example to clearly explain my problem. Assume that : ...
6
votes
3answers
235 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
1answer
59 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 ...
3
votes
5answers
148 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 ...
1
vote
1answer
37 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
124 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 ...
3
votes
4answers
273 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 ...
2
votes
1answer
94 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
196 views

Compile with array operations

When I use the function f with only the Module ...
3
votes
1answer
117 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) ...
1
vote
1answer
71 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 ...
5
votes
4answers
299 views
0
votes
1answer
116 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
103 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 ...
0
votes
2answers
109 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
71 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 ...
3
votes
1answer
309 views

Converting truth tables to boolean expressions

I have a truth table for a Boolean expression represented like this ...
0
votes
1answer
40 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. ...
0
votes
3answers
102 views

How to solve correctly inside a DO loop and then plot

Here is the corresponding code First the equations setup ...
3
votes
5answers
174 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 ...
1
vote
3answers
95 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: ...
2
votes
1answer
67 views

Using Total on a list supplied by a rule

I'm confused as to why Total complains about a nonatomic expression here: ...
1
vote
1answer
62 views

Selecting items in a list based on multiple tests

I have an array of strings that look like this: ...
2
votes
3answers
149 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 ...
1
vote
1answer
94 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
1answer
78 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 ...
9
votes
3answers
426 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: ...
1
vote
0answers
86 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
128 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
39 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 ...
3
votes
1answer
117 views

Select row from a table by column value [duplicate]

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, ...
2
votes
1answer
85 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 ...
1
vote
2answers
132 views

MapThread with List Manupulation

I have the following three lists: ...
2
votes
2answers
339 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
139 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, ...
1
vote
1answer
112 views

How to replace a list with the result list after each iteration [closed]

I have some initial values such as L1 list: L1={10,20,30,40,50}; I want to use the L1 ...