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

learn more… | top users | synonyms (3)

7
votes
5answers
271 views

Find positions of duplicates that are neighbours

Assuming the following list {1,2,3,3,5,6,3} I would like to get the position of values that are next to each other and are duplicates. That is, the output should be {3,4}. Thank you for any help. ...
7
votes
3answers
252 views

When does a list contain only ones?

I am starting with a list of length n that contains all -1's. For instance, when n = 6 the list is {-1, -1, -1, -1, -1, -1}. I ...
13
votes
4answers
1k views

Moving maximum function?

How can I construct a moving maximum function? For example, if I have a list of 12 values: { 5, 6, 9, 3, 2, 6, 7, 8, 1, 1, 4, 7 } and I want to maximize over 3 ...
1
vote
3answers
153 views

Distinguishing slots in a function mapping Position across a list

Suppose that I have a list myList that has more than one level. Here is an example of such a "data structure": ...
2
votes
3answers
118 views

Quickly plotting (number of events) vs. (time) for a very large number of events encoded as pairs of real numbers representing start and end times

I have an array that looks like the following: exampleArray = {{t1,r1},{t2,r2},{t3,r3},{t4,r4},{t5,r5},...}; Where each pair of real numbers $(t_k,r_k)$ ...
21
votes
5answers
490 views

More efficient way of generating list of occurrence counts?

Given a list, e.g., target = {a, b, c, b, c, d, c, d, e, f, a, h, g}, I want to generate a list containing the occurrence count of the corresponding element of the ...
0
votes
1answer
69 views

how to filter out numbers of specific type in a table

I am working with a way to generate a table of some numbers, but the one functions could return the complex numbers which I don't want. I am going to filter out the complex numbers. The only way I can ...
1
vote
2answers
106 views

How to create automatically some matrices for symbolic manipulation?

I want to create in an automatic way some matrices to do symbolic calculations with them. They look like these: $$ \left( \begin{array}{cccc} a & 0 & b & 0 \\ 0 & 1 & 0 & 0 ...
5
votes
4answers
824 views

Select a repeated element in a list

I want to select all elements that repeat 4 times in the list. I propose this code ...
1
vote
4answers
325 views

List manipulation: position & max value combination

Starting with {{0, 0, 0}, {1, 1, 2}, {2, 3, 3}, {3, 4, 5}} I would like to get {{0, 2, 3, 5}, {1, 3, 2, 3}} where the ...
1
vote
1answer
133 views

MapThread multiple functions onto multiple lists

I'm trying to learn the functional style which seems to prevail in Mathematica. I'm having trouble accomplishing the following: Let's say I have multiple lists of arbitrary data (using two lists ...
5
votes
5answers
404 views

Counting 'False' values at the ends of a list

I have table like this: t = {False, False, False, 4.5, 6.789, 1.23, 0.98, False, False} and I want to know how many False values I have at the beginning and at ...
0
votes
1answer
68 views

Why Solve won't work for user-defined function, used for system solving? [closed]

I have a list of x-es, that I transform into a list of tx-es. Also tao is my user-defined function that I don't know the parameters of, but I do know the values I get when I put the tx-es in it. And ...
0
votes
1answer
118 views

Using DeleteCases with multiple AstronomicalData properties

I am attempting to use AstronomicalData and DeleteCases together to remove invalid cases of two properties while listing the ...
1
vote
2answers
112 views

Computing lists using AstronomicalData

Edit: Initially in my question I asked how I could search the database of AstronomicalData["Exoplanets"] and return 2 filtered values that only contained valued ...
0
votes
2answers
96 views

Associate the elements of a table

I have a table form as: table = {{a, 6}, {b, ff}, {c, 2}} I want to associate the first element of each pair from the table to the second element of the pair as ...
0
votes
0answers
54 views

analysing data with MLF using (Oracle) Database connection

I'm testing the MLF package in Mathematica for datamining purpose. I start the databaseconnectivity with the following code: ...
0
votes
0answers
24 views

Threading a single abscissa through a list of ordinates [duplicate]

Suppose that I have the following list, called list. list contains elements X, ...
0
votes
2answers
97 views

Delete False values from a list [closed]

I have table: t = {False, False, False, a <= 456, a <=567, a<= 897} I want to delete all values which are 'False' and make my table to looks like: ...
0
votes
2answers
71 views

How can I make my output to be added to an existing list?

v = {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 1, 1}, {1, 1, 1}} For[i = 1, i < 6, i++, For[e = 1, e < 6, e++ 1, Print[Mod[v[[i]] + v[[e]], 2]] ]] I ...
1
vote
1answer
60 views

Testing a List inside of an Table if it is != 0 [duplicate]

I'm new to mathematica so I hope this is not a too stupid question, but I couldn't find a solution in the mathematica documentation. I've got a normal table, initialized with "0" as entries. In the ...
2
votes
2answers
257 views

How to plot several functions without jumping? (multiple eigenvalues of a system as functions of 2 parameters)

I've been working on this research problem for months with some success by no global/proper solution to the problem. So I have square, Hermitian matrices of various sizes ($8,20,38$ dimensions) with ...
0
votes
2answers
84 views

What's wrong with my use of Do? [closed]

My code is: Do[Print[number[[i ;; (i + 4)]]], {i, number}]. The variable number here is a list consisting of 1000 digits. My ...
0
votes
0answers
84 views

Select {x,y} pairs from a list where x conforms to a rule [duplicate]

I'm working on some pet project and I have a very large list of {x,y} pairs. I want to make a new list containing all {x,y} pairs where x is, let's say, even (I actually need something more ...
3
votes
2answers
152 views

Finding positions of multiple elements in lists

I realise that Position[{2, 4, 8, 16, 32, 64}, 4] will return {{2}} I would like to do something like this: ...
1
vote
1answer
86 views

How to convert each pair of { and } into ( and )? [duplicate]

I am a learn-by-example person. I have no idea to change every { and } to ( and ...
1
vote
1answer
159 views

How to convert the following list into a LaTeX table?

How to convert the output of the following code In[43]:= Func[x_]:=Select[Range[x],Total[IntegerDigits[#]^3]==#&]; Func[1000] which is Out[44]= ...
10
votes
10answers
605 views

Finding neighbors from list

Say you are given the following list: list={{3, 2, 1}, {3, 4, 2}, {2, 4, 1}, {1, 4, 3}}; Two numbers $x,y$, not necessarily distinct, are neighbors if one of the ...
10
votes
3answers
319 views

Zero-dimensional matrices

In a recent Mathematica project, $(n \times 0)$- and $(0 \times n)$-dimensional matrices have suddenly become a frustratingly common edge case for me. For instance, consider the following two ...
10
votes
3answers
230 views

Can I return lists with different dimensions from a compiled function?

Sometimes I'll need several lists with different dimensions to be returned by a compiled function, but compiled function will fail if an irregular list contained: ...
4
votes
4answers
317 views

Deleting powers of a common prime except the highest one from a list with further only primes

In a list with factors of which most are prime, some are integer powers of some common prime as base. All the powers from 1 to ...
0
votes
2answers
164 views

Replace all elements of a list

I have a set that looks like: s = {{1, 2, 3} -> 9, {4, 1, 9} -> 9, {3, 7, 3} -> 1}; Now, I want to replace each element of the set by the lhs of "...
5
votes
1answer
167 views

MapThread over large graph

I am trying to build a very large graph with approximately $16\,000\,000$ edges, each being a two-dimensional integer vector. I have a list of edges in the form $\{\{e_{11}, e_{12}\}, \{e_{21}, ...
1
vote
2answers
117 views

Deleting parts from a nested list

I have a very long nested list. Here is a short example: list = {{1.2, {1, 1, 1, 1}, {2, 2, 2}}, {0.9, {3, 3, 3, 3}, {4, 4, 4}}, {1.4, {4, 4, 4, 4}, {5, 5, 5}}} ...
12
votes
6answers
600 views

Elegantly split a matrix into positive and negative parts?

I have a matrix $M$ of real components, and I want to split it into two matrices $M^+$ and $M^-$ of the same dimensions as $M$, where $M^+$ contains the positive components of $M$ (the remaining ...
2
votes
1answer
342 views

Calculate mean square displacements for different particles from a excel file

I have the particle movement data in the following format: ...
2
votes
3answers
117 views

How to do subtraction with sets in which the elements have multiplicity indicators? [duplicate]

I want to do subtraction with sets l1 and l2, which contain multiplicity indicators. For example, ...
6
votes
3answers
223 views

Loop function over list [duplicate]

I would like to divide element 1 of a list by element 2; element 2 by element 3, and so on. What is the best way of doing this? I have tried f = #1/#2 & ...
1
vote
1answer
159 views

How should I go about writing more functional and list based code? [duplicate]

I've heard that Mathematica is usually faster when the code is list-based and/or uses a functional paradigm. I'm still working on getting the hang of this; there are a lot of ...
2
votes
2answers
107 views

Deleting elements on a list by the first element of another list

I was trying to make this L1 = {{2, 1}, {6, 4}, {8, 7}, {9, 5}}; L2 = {{2, 9}, {9, 6}}; L = Union[L2 , L1] And I used this: ...
6
votes
3answers
268 views

Mapping a function that assigns values to a list over a different list

I'm trying to get used to Mathematica's approach to programming and list manipulation, and am struggling with one thing. Say that I have a function f which takes a ...
0
votes
2answers
80 views

Code for sum of exponential divisors function

Consider $n = p_{1}^{a_1}\cdots p_{r}^{a_{r}}$. An integer $d = p_{i}^{b_{i}} \cdots p_{r}^{b^{r}}$ is called an exponential divisor of $n$ if $b_{i}$ divides $a_{i}$ for every $1\leq i \leq r.$ I am ...
1
vote
1answer
103 views

How to apply compiled function on list

Compile function output error: How to apply compiled function on list? ...
2
votes
1answer
69 views

Convert Integer to Numeric with Replacement rules

I have a long list of triples, each looking something like {AGO, 1988, 2345.23}. Some of these, however, have an integer in the third spot, like this: ...
1
vote
0answers
121 views

Using Part within a Compiled Command

I'm looking to define a multi-line function that makes use of the "Part" command. A toy example: ...
1
vote
0answers
69 views

Produce {f[x],g[y],h[z]} in as many ways as possible [duplicate]

I have two lists of equal lengths but for my task I will use 3-element lists , namely {x,y,z} and {f,g,h}. The first contains ...
1
vote
2answers
106 views

Add a column to a matrix as a function of the other columns

I was wondering if its possible to add a column to a matrix by a formula that uses all other columns, like this: ...
0
votes
3answers
403 views

Find the number of nonzero elements

How do you find the number of elements in a matrix that are non-zero. For instance, the following matrix has 5 nonzero elements. ...
0
votes
1answer
188 views

Performing matrix multiplications with a list

I have a question in regards to PseudoInverse. I have $A$, an $n\times 2$ matrix, and when I want to compute $(A^T A)^{-1}A$, by using ...
6
votes
2answers
118 views

Get brief help for a set of functions

When we are in console mode or working with a notebook we can get brief help about a function just by shift-entering ?function I would like to have a list like ...