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

learn more… | top users | synonyms (3)

3
votes
1answer
53 views

Output function control and manipulation for efficient computation

I have taken note of a similar post related to modifying function parameters. I tried to adapt Kuba's solution to this post but I can't get it to work. I will illustrate my problem using a similar ...
0
votes
2answers
36 views

Constructing a table from a constraint on another table

I have a 1000X6 table, where in each row the first three columns are dependent on the second three. I then make smaller tables of 1000X2 from these first three columns and basically ...
1
vote
2answers
82 views

How to select elements from a list by condition?

Considering I have a list: F = {f1, f2, f3, f4} I want to perform exponent on the list F = Power[#, 2]& /@ F Now I ...
1
vote
3answers
142 views

Defining functions when there are a lot of parameters

Suppose I have two lists of parameters: $\delta=\{\delta1, \delta2, …\}$ and $\gamma = \{\gamma1, \gamma2, …\}$. The question is: how can one use $\delta$ and $\gamma$ (the parameter vectors) within ...
2
votes
2answers
88 views

Inverse of Times->Sequence

Suppose there is a list list={abc} then the replacement Times->Sequence gives ...
1
vote
2answers
58 views

Inconsistency in arithmetic on list elements [on hold]

As expected, {a,b,c} - {a,a,a} (* {0, -a+b, -a+c} *) Or the same result can be obtained with less typing, thanks to implicit duplication of the subtrahend: ...
6
votes
3answers
311 views

Functional equivalent of a For loop referring to consecutive elements in a list

I have implemented this function which smooths the values in a list by, if it encounters a zero, replacing this entry by the average of its two neighbours (apart from the first and last values of the ...
8
votes
5answers
496 views

How to subtract one list from another, treating each elements as distinct? [duplicate]

Suppose that I have a = {"A", "A", "A", "B", "B", "C"} b = {"A", "B"} How can I subtract b from ...
1
vote
1answer
31 views
22
votes
8answers
1k 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}
29
votes
5answers
2k 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 ...
12
votes
1answer
201 views

The efficiency compare between Flatten[#, 1] & and Join @@ # &

Err..Often I met the situation to join lists at the first level and I used to just Flatten[#, 1] &@ them. However, I found(when glance over the mathematica.stackexchange.com) someone else prefer ...
6
votes
4answers
155 views

Duplicate mapped elements in Riffle

What is the best way to do this? in: {a, b, c} {d, {e, f}, g} out: {{a, d}, {b, e}, {b, f}, {c, g}} ...
0
votes
0answers
20 views

Manipulating nested matrices columnwise [duplicate]

I have a project that requires analyzing large volumes of excel sheets at the same time. I have been having trouble figuring out how to index the imported files and manipulating them. The way I am ...
5
votes
2answers
141 views

What does IndexBy do and how exactly does it work?

I just saw the function IndexBy in the autocomplete suggestions and I was curious to know exactly how it works. Unfortunately, there's no trace of it in the ...
8
votes
5answers
380 views

How to randomly select subsets

I have a list of around 300 elements. I want to sample subsets of length 25 such that my samples are all distinct. My first inclination was to use something like ...
0
votes
1answer
199 views

How do I plot results of complicated calculations in Mathematica?

I am new to Mathematica and am struggling with making plots of how features of solutions vary with parameters. For example, I can find the eigenvalues and zeroes of a Sturm Liouville problem (showing ...
0
votes
0answers
44 views

Removing curly brackets in list [closed]

I have a list from ProteinData["APOE", "MolecularFunctions"]. Is there a way to extract out the list of five functions as a comma -separated list, without the curly brackets?
0
votes
2answers
43 views
2
votes
3answers
94 views

Plot a table of lists

I want to make a point plot of a table with lists in it. Assume I have data like this: data={{1,2,3,4},{5,6},{1,5},{2,4}}; and now I want to make a point plot ...
0
votes
0answers
25 views

Selecting from a list depending on another list [closed]

I have a list of particle positions: parts = {{{x, y}, {x, y}, {x, y},{x, y},{x, y}.....}, {{x, y}, {x, y}, {x, y}, {x, y}, {x, y}.....}, ......} So it ...
0
votes
2answers
79 views

Making table and plotting results of NDSolve problem

I am trying to solve two equation to find /[Phi][x] and plot h vs. /[Phi][x] for different values of L.I tried by writing as: ...
0
votes
1answer
68 views

Iterating over a 2D list [closed]

I want to collect the result of a function in a data structure. In java the loop looks like the following code: ...
1
vote
4answers
113 views

Pure function, one slot refers to List-position

I used all my google-fu trying to find how to make this work; read the docs as well. What have I missed? I feel sure this can't be a new question, but I can't find anything Here is is: ...
0
votes
1answer
51 views

Compute the evolution of several quanties from a data file

This question is somehow a part II of this: Part I. Here comes a small data sample as a minimal working example: ...
5
votes
2answers
888 views

Dramatic speed difference of code on Matlab and Mathematica

Background: I was trying to convert a Matlab code (fluid simulation, SPH method) into a Mathematica one, but the speed difference is huge. Matlab code: ...
0
votes
0answers
29 views

Remove list head to insert as arguement [duplicate]

I'm trying to use a set of terms, e.g., {x,y,z}, as an argument for another function with doesn't take in a list but a series of variables (e.g. need ...
10
votes
5answers
506 views

Best way to modify values in a list of rules?

Recently I had to solve a problem similar to this: Let's say I have a list of list of rules ...
0
votes
2answers
99 views

Exclude elements from mapping

I have had this problem way too often and still have not found a solution, yet. One acually used code is:` ...
1
vote
0answers
53 views

List manipulations with ; and ;; [closed]

I have the following list: L = {{a1,a2,a3,a4},{b1,b2,b3,b4},{c1,c2,c3,c4}} By using just the ; or ...
0
votes
1answer
55 views
0
votes
2answers
117 views

Contract two lists

Suppose I have two lists of the equal length in the form powers= {{rho th},{mu},{beta},{nu},{r},{}} ...
0
votes
0answers
45 views

Appending elements to a list in parallel table

Is there any way to store values in a list that is being computed in parallel? For example, if ParallelTable is computing some ...
1
vote
2answers
60 views

Encoding variables

I'm trying to fit a Logistic Model using LogitModelFit in Mathematica. The data I'm using contain qualitative variables that I have to encode. I've searched in ...
2
votes
1answer
103 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 ...
0
votes
0answers
22 views

Iterating a model with 2nd order difference equations using Manipulate [duplicate]

I have a model including first and second order difference equations. It works for the case of first difference equation, which is below: ...
0
votes
0answers
33 views

Error with AppendTo [duplicate]

I am trying to write a function that builds a graph, or - better said - adds a layer of leaves to a pre-existing graph. Basically, I hand to the function three lists. ...
1
vote
1answer
144 views

LinearModelFit[] of simulated data

I'm trying to simulate Hooke's law, f = k * x, so I generate data with the code: ...
4
votes
2answers
92 views

Finding column-wise ranks of values in a multidimensional list

I often have to find ranks of values in a list. However, Mathematica does not have built-in functions for that, or may be I'm just not aware of them. I can easily find ranks of a row/column vector. ...
0
votes
0answers
25 views

Extracting subscript and superscript [duplicate]

I have an expression in the form Power[Subscript[g,a],mu] and I need to extract "a" and "mu" from this expression. It should be very simple but I could not find ...
7
votes
5answers
322 views

Calculating weird numbers

A weird number is a number such that the sum of the proper divisors (divisors including 1 but not itself) of the number is greater than the number, but no subset of these divisors sums to to ...
20
votes
3answers
739 views

DeleteDuplicatesBy is not performing as I'd hoped. Am I missing something?

Déjà vu: a new-in-v10 function should provide a better solution to an old problem, but my enthusiasm is curbed when I run timings. This time the function is ...
1
vote
1answer
63 views

Importing, sorting and exporting lists

I have several TSV lists (.txt) of something like 2000*2000 numerics (e.g. 1.8645) to import ...
0
votes
0answers
63 views

Autocorrelation of 3D Points

I'm trying to compute the autocorrelation of a list of points (x,y,z) in 3D. Can the CorrelationFunction or maybe ListCorrelate ...
-1
votes
1answer
40 views

Convex Combinations of List Elements

Let's say I have two lists $L_1=\{a_1,...,a_5\}$ and $L_2=\{b_1,...,b_10\}$. Is there an easy way to make new lists from convex combinations of these two lists' entries? Let me be more specific: 1 ...
1
vote
6answers
143 views

Converting two lists into a list of tuples [duplicate]

I wonder how I can turn the list $\{a_1,...,a_n\}$ into the new list $\{(a_1,1),...,(a_n,n)\}$, i.e $a_k \mapsto (a_k,k)$, how do I do that? I figured the function Tuples might work, but it just ...
0
votes
1answer
34 views

Delete String sub list

I have a list with several sub lists containing either strings or integers. I'd like to delete all list with strings. The following list ...
2
votes
3answers
111 views

Function like Cases/Select which also returns complement

I'm looking for a function similar to Cases or Select, but that also returns the complement of the resulting list. In other ...
20
votes
1answer
461 views

Convex optimization

I am playing with some Compressed Sensing (think single pixel camera) applications and would like to have a Mathematica equivalent of a Matlab package call Convex Optimization (CVX). Specifically, I ...