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

learn more… | top users | synonyms (3)

0
votes
0answers
40 views

Don't understand why my Do-loop is misbehaving [on hold]

I have a 2D array, initialized by array = ConstantArray[0, {10, 1000}] and I want to assign numerical values to ...
0
votes
0answers
34 views

Unknown number of variables in a logical statement [on hold]

Resolve[ ForAll[{i, y[i]}, Implies[i >= 0 && i < 3 && Implies[i < 3, y[i] > 0], Sum[y[i], {i, 0, 2}]>0]]] returns ...
0
votes
2answers
29 views

Selecting elements from a list [duplicate]

I have the following array of numbers: a = {{0, 2, 5}, {3, 5, 1}, {4, 0, 5}, {8, 3, 4}, {0, 8, 6}}; then I make a list of the first row with ...
0
votes
0answers
46 views

Improve performance of processing transactions in a large file

I want to work with a table which has 296,705 transactionslines and 172,147 transactions. ...
2
votes
1answer
50 views

Removing characters from non-strings

I have a large list of lists that contains mixed data, some real, some strings. The lists are of various lengths and depths. Some of the real data values have an asterisk appended to them, e.g.: ...
0
votes
2answers
41 views

Select over many lists with changing selection criteria

I have many individual timeseries I am trying to align and compute the mean and other statistics for. The problem I am having is that I am only interested in aligning a particular part of each ...
1
vote
1answer
23 views

Export nested list with complex structure

I have a list that looks like this l = {elem1, elem2, ...} Where elem_={t, {d1,d2,d3} } How can I export it? I tried ...
1
vote
1answer
42 views

Let's do this list-rearrangement prettier [duplicate]

Suppose that i have a list in this format= $list=\{ \{a,obj1 \} ,\{c,obj2 \}, \{a,obj3 \}, \{b,obj4 \} \dots\}$ I want to construct a new list in this way: $ newlist= \{ \{ \{a,obj1\} , \{a,obj3\} ...
3
votes
5answers
430 views

Determine if all the zeros in a list occur at the end

I have a collection of (short) lists of nonnegative integers. For each, I would like a predicate that decides if all of the zeros in the list appear at the end. For example, ...
0
votes
0answers
43 views
6
votes
3answers
200 views

How to build a matrix from a set of vectors and other matrices using ArrayFlatten

I want to build a 6 by 3 matrix, from the following: one vector is 3 by 1, then a matrix, which is 3 by 2. These will go to the top 3 rows. Now the bottom 3 rows, I'll have 3 vectors each is 3 by 1. ...
2
votes
3answers
117 views

How to extract both first and last rows of each group from unbalanced panel data

This is a follow up question form my last question click here. I have unbalanced panel data such as : ...
5
votes
2answers
217 views

Generate cyclic list from a list

Given a list (for example, {3, 5}) I would like to make a function genCyclic[n_, list_] which generates a cyclic patterns of ...
0
votes
0answers
41 views

How to make Position work right? [on hold]

I have a variable called t[1]. This happens: a = { t[1], 1}; Position[a, 1] (* {{1, 1}, {2}} *) How do I make Position find the 1 and not variables that ...
1
vote
0answers
59 views

Find algorithm or generator formula with automated procedure and pattern recognition

I am trying to find a generator formula for the discriminant of a polynomial and believe it would be an interesting problem for the Mathematica community to know how to automate evaluation of certain ...
5
votes
4answers
208 views

How can I get a list of the positions of the running minima in a list?

I want the positions of the (sequential) running minima in a list, that is, the positions of entries that have the minimum value of all the elements in that list, up to and including that entry. For ...
3
votes
3answers
115 views

List manipulation: Dropping first or last row or column of a matrix

How do I drop the first/last row or first/last column from a matrix? The general case is answered here but I am new to Mathematica and it the arbitrary case is unnecessarily complex. Suppose I am ...
0
votes
1answer
34 views

Elements inside arrays seem to be strings rather than signed numbers

When I have code like b = Array[Subscript[be, #] &, {3, 1}] b = b /. {Subscript[be, k_] :> Subscript[-be, k] /; k > 1} I am noticing that Mathematica ...
4
votes
3answers
147 views

Replace elements in matrix to make it symmetric using automated procedure

I am generating a matrix using (mat2 = Array[Subscript[a, ##] &, {4, 4}]) // MatrixForm but would like to force Mathematica to make it symmetric. Thereby I ...
0
votes
2answers
41 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
3answers
151 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 ...
1
vote
2answers
59 views

Inconsistency in arithmetic on list elements [closed]

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: ...
2
votes
2answers
90 views

Inverse of Times->Sequence

Suppose there is a list list={abc} then the replacement Times->Sequence gives ...
6
votes
3answers
317 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 ...
1
vote
1answer
33 views

Replacing Logic operator List and generate combination of variables

so I'm trying to do the following starting from a list of inequalities: ...
12
votes
1answer
207 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 ...
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 ...
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}} ...
6
votes
2answers
144 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
390 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 ...
3
votes
1answer
62 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 ...
2
votes
3answers
101 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
2answers
43 views

Table results within loops

I have the following code. ...
0
votes
1answer
69 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: ...
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: ...
1
vote
2answers
84 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
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
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 ...
5
votes
2answers
897 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: ...
1
vote
0answers
54 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
2answers
81 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
61 views

Code optimization, Pad missing keys and Total part of values [closed]

Code optimization, Pad missing keys and Total part of values ...
1
vote
2answers
61 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 ...
3
votes
1answer
119 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
48 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 ...
0
votes
2answers
118 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
23 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. ...
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 ...
4
votes
2answers
94 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. ...