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

learn more… | top users | synonyms (5)

4
votes
3answers
153 views

Problem with Conditionals: Why does mathematica add an extra empty list to my output

I have a set of positions where I want to slice a list of numbers. If I Total the values in that list, and they are greater than or equal to 1, I want to remember ...
3
votes
5answers
80 views

Insert or Remove randomly

I have a series of characters such as "ABCVABVCCAVB". I wish to randomly remove or insert character. I could make to remove case like deleting all A, or B,... but I wish to remove or insert only 1 ...
1
vote
1answer
37 views

How to make a repetive procedure with LinearModelFit [closed]

I start with a list of lists: ...
-1
votes
1answer
62 views

Jumping from one dimension (1D) to two dimensions (2D) Part II

Here is a sample data file data = {{-10,3,1},{-7.5,12,3},{-1.5,5,2},{2,4,4},{3,7,4},{6,9,5},{7,1,5}, {8,3,1},{9,12,2},{10,8,5}}; The first element of the list ...
0
votes
1answer
71 views

Jumping from one dimension (1D) to two dimensions (2D)

Here is a sample data file m = {{-10,3,1},{-7.5,12,3},{-1.5,5,2},{2,4,4},{3,7,4},{6,9,5},{7,1,5}, {8,3,1},{9,12,2},{10,8,5}}; The first element of the list ...
0
votes
1answer
53 views

Timing and memory use is critical:fast partitioning of binary sparse array

I do experiments were I measure a signal, and I need to know at what time points it is above a threshold. If at a given time point, the signal is above the threshold, then a '1' gets put into the ...
3
votes
1answer
60 views

How to make a table with from two lists?

I have two lists. ...
2
votes
3answers
78 views

Applying boolean logic to a 2D array

How can I make a function that creates a particular size 2D matrix that determines "True" or "False" if a random value between 0 and 1 is at or below a certain number? Below is what I have written but ...
6
votes
3answers
129 views

How to remove duplicate elements from two separated lists efficiently?

I have two lists of elements: indices = {Prime /@ Range[5000], Prime /@ Range[100, 300]} // Flatten; values = RandomReal[100, 3] & /@ Range[Length[indices]]; ...
2
votes
2answers
41 views

Partition a list into TradingChartformat

I want to make a stock chart by using TradingChart with my own data. But, the imported data is in the format ...
1
vote
2answers
72 views

Sum of a set of elements in a array?

For a function I do this (Integrate over circular range): NIntegrate[x*y Boole[Sqrt[x^2 + y^2] < 3], {x, 1, 5}, {y, 1, 5}] ...
0
votes
0answers
31 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 ...
3
votes
1answer
87 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 ...
6
votes
2answers
67 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 ...
3
votes
6answers
253 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 ...
6
votes
1answer
62 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 $$ ...
-1
votes
1answer
236 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 ...
6
votes
1answer
116 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 ...
3
votes
3answers
111 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: ...
0
votes
3answers
47 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 ...
2
votes
2answers
93 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 ...
4
votes
8answers
186 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. ...
2
votes
1answer
102 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?
2
votes
3answers
62 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 ...
5
votes
3answers
405 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 ...
3
votes
1answer
62 views

How to multiply a row to multiple rows in a matrix

I have the Following Matrixes; ...
1
vote
1answer
215 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 ...
0
votes
1answer
62 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: ...
1
vote
8answers
252 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: ...
4
votes
3answers
145 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 ...
10
votes
6answers
279 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 ...
4
votes
2answers
130 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 ...
0
votes
1answer
113 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
votes
2answers
48 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, ...
3
votes
3answers
111 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: ...
5
votes
4answers
106 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 ...
3
votes
2answers
256 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 ...
4
votes
2answers
120 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 ...
4
votes
2answers
132 views

Extract part of a matrix

I have imported a matrix from a .txt file (it could be better from an Excel file): ...
9
votes
6answers
320 views

Converting a list of rules to a list of lists

What are some easy ways to convert the list of Rules ...
13
votes
5answers
378 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 ...
5
votes
2answers
143 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 ...
3
votes
2answers
75 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 ,...}} ...
5
votes
4answers
114 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. ...
0
votes
0answers
77 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 ...
5
votes
4answers
181 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 ...
1
vote
1answer
95 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 ...
0
votes
1answer
75 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 ...
0
votes
1answer
51 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 ...
1
vote
4answers
109 views

position with multidimensional array

I have this code: ...