# Tagged Questions

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

32 views

### Printing the name of variable in a list as a string [duplicate]

I have a list of objects MyList = {OII,IOI,OIO} where every object is a vector (the names are for ease of use, since they stand for 011, 101, 010). For example ...
94 views

### Extreme Slowdown with Fold

I am doing a finite difference model, and need to create a list recursively. For a small list, Fold is extremely fast, but when the list becomes large enough, Fold becomes extremely slow. Here is the ...
72 views

### A problem about matrix/vector extension via $\tt ArrayPad$

Given that I have a vector and matrix as follow: vec = Array[Subscript["P", #] &, 6, 0]; mat = Array[Subscript["P", #1, #2] &, {5, 4}, {0, 0}]; And I ...
264 views

### Joining strings in every third element in a list

How do I join a string to the first and every third element in the list? Example: list={1,2,3,4,5,6,7,8,9..} ={"string1",2,3,"string4",5,6,"string7",8,9..} I ...
73 views

### Matrix Multiplication after “Flatten”

Say we originally had two matrices, $A$ and $B$, both $n \times n$, whose product $$C= A.B$$ Now I flatten $A$. I can obtain a flatten $C$, from the following multiplication  C_{flat}=A_{flat}....
287 views

### Tweaking a code for basins of attraction

NOTE: Whoever finds a working way for obtaining the basins of attraction in the $(x,\mu)$-plane will add his/her name along with @Quantum_Oli in the list of the acknowledgements of the resulted ...
122 views

### List consisting of positions of the matrix elements and the elements themselves

Given a 2D matrix I would like to make a list with elements consisting of positions of the matrix elements and the elements themselves. Let the matrix be ...
118 views

### How can I make custom accumulated sequences like the following?

First of all, I don't really know how to formulate the question, so if you understand my question and know a better way to phrase it, please revise. I have the following Matrixes: ...
48 views

### Calibrating the length of a list [duplicate]

Suppose you want to create a uniform square grid of initial conditions on the (x,y) plane. This can be done using ...
104 views

### Repeatedly apply a bivariate function with one argument running over a list

I'd like to know how, given symbols f and g, and a list {a,b,c,...}, to produce the ...
232 views

### How to Select from a List based on another List? [duplicate]

I could do this with Append[], If[], and a Do[] loop, but I'm sure there's a more elegant "Mathematica-like" way. Example: Selected the elements of b where the corresponding element of a is >3. <...
108 views

### Minor question about optimally increasing last item of a list

What is the best way to increase the last item of a list by one? I've come up with ++list[[Length[list]]], is there something more efficient?
84 views

### How can I create a dynamic Matrix inside a function?

I have a function where a n parameter is handed and a list of values is calculated inside of it. I then need to solve a linear system of equations that require me ...
420 views

### Riffle an element with +1 every time

I've been struggeling with the command riffle. input: list = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}} How do I use riffle like this, but add 1 to "X", every time it gets ...
67 views

### How to multiply a row to multiple rows in a matrix

I have the Following Matrixes; ...
270 views

### Basins of attraction of equilibrium points

The Henon-Heiles potential is the following V = 1/2*(x^2 + y^2) - y*(1/3*y^2 - x^2); which has four equilibrium points ...
64 views

### Insert a string and add 0.5 in the last element in every list after [closed]

How to insert a string after every 3rd list and then add 0.5 on every Z on every list after? Input: ...
268 views

### Insert an element into the end of every list [closed]

I have made a list partition and would like to insert an Element X into the end of every partition. Input: ...
199 views

### Operations in nested lists

New to Mathematica, I have a nested list containing many lists(A) of 16 lists(B) of 3 integers(C). I wish to put in each (Aj, Bi, C2) the result of (Aj, Bi-1, C2)+(Aj, Bi, C1). I could do it with a ...
339 views

### Split according to List and apply rule

I have a list which looks some thing like this {a1, a2, a3, a4, a5, a6, a7, a8, a9, a10} Now I want to split it according to lengths ...
139 views

### ReplaceRepeated as a Looping construct?

There are a lot of discussions about looping constructs (notable example here). Wolfram language guides, as usually, contain most relevant links. Looping constructs guide has the following part on ...
135 views

### How to plot point by point in a for loop?

I first apologize for my english which is still approximative and for the spelling, I hope all will be clear. My problem is the following: I need to first solve a non-linear implicit 2-...
49 views

### Retaining rows with only non-zero values in a large table

I am not sufficiently proficient in Mathematica so my question may be stupid, apologies. I have a long table with chronological data over several variables. In some instances, the data are missing, ...
114 views

### Measuring multiple incidences of a continuous constant in a list

I had a hard time trying to word this question properly; I apologize... So I have a (very) big list of 0's and 1's: AllTimes = {{0}, {0}, {0}, {1}, {1}, ...} ...
117 views

### Distribute an integer $m$ to lists of length $n$ in all possible ways? [duplicate]

I need a function that creates a table of all possible lists of length $n$ which contain integer entries that sum up to the same given number $m$. For example, if we consider lists of size $n=3$ and ...
265 views

### Repeatedly applying a function

I have a list of numbers: allNums = {2, 5, 10, 17, 26, 1, 3, 7, 13, 21, 31, 1, 2, 11, 28, 53, 1, 6, 19, 40, 69} I calculate all possible pairs of two numbers ...
108 views

### Insert elements in several positions in a list [closed]

How to insert multiple elements in a list? list={1,2,3,4,5,6,7,8,9} Output: ...
164 views

### Finding the positions DateList dates in a range in large data set

There are similar questions to this like list search but this question is focused on finding at subset of dates in DateList format within a range of specified dates ...
141 views

### Extract part of a matrix

I have imported a matrix from a .txt file (it could be better from an Excel file): ...
383 views

### Converting a list of rules to a list of lists

What are some easy ways to convert the list of Rules ...
400 views

### Pick elements from list “separately”

I have the following list I want to pick elements from: mylist = {1, 5, 7, 3, 4, 7, 2, 9, 9, 1, 10, 12, 2, 64, 34, 64} I have another list with 0's and 1's which ...
147 views

### Extending a list

I have a range of n integers (always starting at 1) which are 1 apart, f.e. Range[10], Range[17] or ...
78 views

### union several arrays of same flag(date for example) efficiently

Suppose I have several arrays from data files which look like: arrayi = {{datei1, xi11, xi21, ...}, {datei2, xi12, xi22, ...}, ..., {datein, xi1n, xi2n ,...}} ...
153 views

### SubsetQ[] without ignoring duplicates

How could one create a code that checks whether a set is a subset of another, but not ignoring the duplicates? For example, $\{1,1,1\}$ would be a subset of $\{1,1,1,1\}$, but not vice versa. ...
85 views

### Nestlist inside Compile

My question is a continuation of question1 and question2, but I think it may be considered as a self-contained one. I am interested to make the following code faster ...
192 views

### Concise alternative to First@First@Position[…, 1,Heads->False]

Is there a more compact way to accomplish this: lst = {0,0,7}; idx = Position[lst, Except[0], 1, Heads -> False] // First // First (* => 3 *) For ...
98 views

### Iterations in Mathematica [closed]

this is probably a very easy question for all of you. I have a stochastic Mathematica code (not important what it's exactly) which gives me a number at the end. Now I want Mathematica to run this ...
140 views

### Mean squared displacement of a single trajectory

I have a single particle trajectory and would like to calculate the mean squared displacement. The particle is moving from blue over yellow, green to red data points. The {x,y} data are available ...
77 views

### How to make a maximum intensity projection of 3D data?

I am trying to make a maximum intensity projection of my 2D data, which has several intensity values in the third dimension and therefore makes the data 3D. So I want to take the maximum intensity of ...
126 views

### position with multidimensional array

I have this code: ...
175 views

58 views

### Extracting a random sample from a list [closed]

This is sample data data = {{1, 1, 1, 1, 1, 1}, {2, 2, 2, 2, 2, 2}, {3, 3, 3, 3, 3, 3}, {5, 5, 5, 5, 5, 5}, {6, 6, 6, 6, 6, 6}} My actual data contains ...
67 views

### ReplacePart with processed value [closed]

To illustrate, suppose I want to change the {2,2} element of a matrix. If I know the replacement value, I can just make the replacement. ...
42 views

### How to Framed the element which is in a approximate connectional line between any two position in non-square matrix

As you see,I can Farmed the diagonal element: ...
57 views

### Replace rows based on index with different rows

I have a list and I want to replace all rows that are given by index pos with rows from different list. But the rows in different list are sequential while the rows in the original list that need to ...
96 views

### Sum selected rows/columns and replace them with the sum

I have the code: pos = {2, 3, 5}; tbl = Table[i*j, {i, 6}, {j, 3}]; totRow = Total /@ tbl[[pos]]; which defines some row indices (pos) and a table and some of ...
509 views

### Does Mathematica have a functional programming idiom to loop over a list till a condition is met? [duplicate]

The module below takes a list of integers and performs fadic addition on it (if a bit slowly). ...