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

learn more… | top users | synonyms (5)

2
votes
2answers
98 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
206 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. ...
3
votes
1answer
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?
2
votes
3answers
76 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
413 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
67 views

How to multiply a row to multiple rows in a matrix

I have the Following Matrixes; ...
1
vote
1answer
252 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
63 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
261 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
155 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
5answers
327 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
134 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
126 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
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, ...
3
votes
3answers
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: ...
5
votes
4answers
115 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 ...
4
votes
2answers
261 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 ...
1
vote
0answers
96 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: ...
4
votes
2answers
145 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
138 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
351 views

Converting a list of rules to a list of lists

What are some easy ways to convert the list of Rules ...
14
votes
5answers
393 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
146 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
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 ,...}} ...
5
votes
4answers
146 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
83 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
188 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
96 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
121 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
65 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
119 views

position with multidimensional array

I have this code: ...
2
votes
3answers
166 views

Give a common denominator to a whole list

If I have a list, say ...
15
votes
5answers
548 views

A quicker than outer

I need to get a matrix $\{a(x_i-x_j)\}$, where $x_i$ form a partition of an interval, $a(x)$ is a given function. I use ...
-1
votes
1answer
57 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 ...
2
votes
2answers
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. ...
1
vote
1answer
40 views
2
votes
3answers
55 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 ...
2
votes
4answers
91 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 ...
6
votes
1answer
461 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). ...
2
votes
0answers
39 views

Product of two list of different size [closed]

This has to be very easy, but i can find it. I have 2 list a={8, 15, 12, 1, 13, 21, 14, 4, 15} b={3, 19, 29, 47, 13} What ...
3
votes
1answer
63 views

Generate a new list

Suppose we have the following sample data ...
8
votes
2answers
202 views

How to interleave data in a certain way

Here's the deal: I have a table that has the form list = {{A,{a,b,c}},{B,{d,e,f}},{C,{g,h,i,j}}} and so on, where the innermost lists can have an arbitary ...
1
vote
0answers
83 views

How to get the values out of Alternatitves? [closed]

Saying we have something like: SomeFunction[ ... { Alternatives[1, 2, 3] :> "something" } ... ] How can I know if ...
10
votes
4answers
334 views

How to take and evaluate a specific part of a list without evaluating the rest?

I have a large list, for example, lis = {x + y, x y, Sin[x] y + Exp[y], x^2 y} and its elements depend on variables x and ...
2
votes
3answers
60 views

Cardinality of members of a list [closed]

I have to count all the words in a book. I need the cardinality (occurrence) of all the words. {{Table,30},{the,200},{apple29}, etc... I Splitted, and StringTrimed ...
1
vote
1answer
99 views

Find intersections points with axes

Let's create some points corresponding to a simple closed curve ...
6
votes
3answers
129 views

Grouping words by their differences

I'm a new guy here and I face a problem. I should pair the following words according to the rule: pair the words, that differ by max. 2 characters, like: ...
5
votes
1answer
96 views

How to order a list to match the order of another list?

How can I order a list to match the order of anoter list ? For example: Suppose I have the lists x = {3, 1, 5, 7} and ...
0
votes
1answer
31 views

add " for all member of the last (1 and -1 positions)

I have a small problem with a list. I did, that list={AA,BB,CC} and I wish to make it into the form of {"AA","BB","CC"}, but I cant insert ", because failing, I tried simply adding, or MapThreading, ...
1
vote
2answers
62 views

Creating authomatically inequalities/equations from a list of polynomials

I am trying to learn how to make automatically from a list of polynomials (or an arbitrary collection of algebraic expression) a list of inequalities/equalities (those will later serve as constraints ...