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

learn more… | top users | synonyms (5)

3
votes
2answers
100 views

How to generate a limited number of tuples of a list and not all?

I have a question for which I couldn't find an answer: how can we generate only a given number of tuples of a list and not all of them? For instance, I want to have only the first two 3-tuples of ...
5
votes
4answers
198 views

Creating Nested For Loops for modifying values to append to a List

Basically, the title says it all. I am familiar with python, not so much with mathematica. For the program, I am starting out with three unique lists of values for which I am using a triple nested ...
3
votes
4answers
253 views

Duplicating and arranging a list

I have a list, {a,b,c,d,...,z} And I want to duplicate that list n times such that, {a,a,a,b,b,b,c,c,c,....z,z,z}. I ...
1
vote
2answers
101 views

How Do i Extract Only The Coordinates xyz (Number) From This Log file

this Log contains the information of all coordinates of many atoms in a molecular dynamics simulation for a long sequence of time steps, along with some extra information other than the coordinates. ...
1
vote
2answers
75 views

How to repeat a set of operations on a single data set?

I am very new to Mathematica and I just couldn't figure out the solution for the following problem. I am trying to iterate the following functions for 10 times. For instance, "a" to "fullData". The ...
1
vote
0answers
46 views

List manipulation, averaging over lists and fidelity

I want to create vectors from a function poly[α_, β_, δ_, ϕ1_] were several variables (α, β, δ) are randomly sampled from a unit sphere. Then I want to vary another ...
0
votes
2answers
65 views

Plotting cicle using ListPlot

How can I plot circle plot with ListPlot function or how to organize data to produce circle plot from ListPlot function ? If u do something like this ...
3
votes
1answer
101 views

Replace list element with element from another list based on condition

I Have a list on integers and another list of "duplicates". E.g. start={{3},{1},{2},{4}}; duplicates={{1,4,7},{5,6}} I would like to substitute each element of ...
11
votes
9answers
743 views

Forming an upper triangular matrix from the elements of a list

I asked this question before, but i was closed because it the question was not comprehensible enough. So i reworded it, hope that's ok. I have a list with 6 elements. ...
8
votes
4answers
230 views

How to get this list with a terse method

If I have like {a,b} and I want to get {{a+1,b},{a-1,b},{a,b+1},{a,b-1}} We don't care about the ordering of the ...
0
votes
1answer
30 views

Iterating KroneckerProduct[] and returning the result from a function

I am trying to write a function which will take a matrix m and an integer i as inputs. Then it will compute the Kronecker product of m with itself i times and return the result. The code is as ...
3
votes
4answers
176 views

select elements in a list

I am new in Wolfram Math and I need a help in making a simple program. Let's suppose we have a list: list = {{1, 11}, {2, 7}, {4, 2}, {7, 9}, {-2, 3}, {-1, 10}}; ...
4
votes
3answers
125 views

Alternative forms to Table for iterating over replacement rules

I have a multivariate polynomial x. I get coefficients of various monomials using CoefficientRules, which returns a list of ...
-1
votes
3answers
76 views

Create table of elements which belongs to specific sets

I would like to produce elements (preferably by Table or For-If commands) that they belong to specific sets. For example I want to write positive integers from 1 to 100 such that they are $2 \pmod 3$, ...
1
vote
1answer
82 views

How to determine distance of periodic features in measured dataset

I have a list of x- and y-values associated with a measured height (z-values). Part of the list is plotted below. As you can see, there is a periodic arranged structure, namely a cross. Now I would ...
9
votes
1answer
192 views

Fast implementation of Metropolis-Hastings update with multiple sets

This is an optimisation question rather than something I am unable to do. I have a naive, primitive working version of the code (I submit it below) but I am trying to make it work faster. I am asking ...
2
votes
3answers
233 views

How to use Select with lists

I am trying to do: Select[minimus[[6]], #1[[2]] < (min[[6]] + emin[[6]]) &] applied to all elements of minimus, ...
0
votes
0answers
29 views

factoring a phrase of matrix elements and calculating main eigenvalues

I have a question containg two parts: 1-If we have a matrix as ...
15
votes
9answers
620 views

Any built-in function to generate successive sublists from a list?

Given lst = {a, b, c, d} I'd like to generate {{a}, {a, b}, {a, b, c}, {a, b, c, d}} but using built-in functions only, ...
6
votes
3answers
309 views

Indicate minimal path sum

Described on the page: http://www.mathblog.dk/project-euler-81-find-the-minimal-path-sum-from-the-top-left-to-the-bottom-right-by-moving-right-and-down/ It is an example of the solution indicated in ...
0
votes
1answer
48 views

How to pad numbers to the border of the Matrix?

I want to pad the numbers,but it throws an error Part::partw,so I use Quiet to suppress this error. ...
3
votes
1answer
69 views

Calling results of applying f to expr inside NestList

Being new to Mathematica, I try to follow the suggestions of using NestList, Map, Table ...
6
votes
1answer
42 views

Heading in Table Form Question

I have: modadd = Table[Mod[i + j, 3], {i, 0, 2}, {j, 0, 2}]; TableForm[modadd, TableHeadings -> {{0, 1, 2}, {0, 1, 2}}] Which produces: How can I put a ...
3
votes
1answer
227 views

Minimize sum of array elements subject to conditions

I have array where each point at different times are shown parameters ...
0
votes
4answers
50 views

insert elements into 2 D array [duplicate]

say I have a 2 dimensionsal array like a={{1,2,3},{4,5,6},{7,8,9}} and a vector like v={10,11,12} I want the result to be ...
4
votes
1answer
103 views

UpTo for negative indices?

The symbol UpTo emerged as a sort of "safe take" in version 10: Take[{1, 2, 3}, UpTo[4]] (* Out: {1, 2, 3} *) But it wasn't ...
6
votes
2answers
343 views

Performance of calculation of means squared displacement

How can I improve the performance of the following code which calculates the mean squared displacement for coordinates stored in data? Here for each time difference ...
8
votes
2answers
97 views

For loop works at top-level but not in a function

Why does this work: For[i = 1, i <= Dimensions[list][[1]], i++, list = Insert[list, i, {i, 3}]] But this doesn't: ...
2
votes
2answers
81 views

Group Datasets and take minimum/maximum

Good Morning I have the following dataset: And I try to reach this output: key: only one row per key text: join all texts of the rows with the same key (but no duplicates) min: take the lowest ...
3
votes
2answers
79 views

Generating a sequence of lists [closed]

I have learnt how to generate a sequence of numbers, but now I come across a question whether it is possible to generate e sequence of lists. Say, I would like to generate ...
8
votes
3answers
345 views

Give a element rank list of a list

SeedRandom[417] list1 = RandomChoice[Range[22, 28], 4] {22, 24, 26, 23} We can get the rank list ...
1
vote
1answer
51 views

Rearrange the list with some rules

I am trying to solve physic problem on operators which are not commute. However, I am not good at coding, so I am having some problem with Mathematica code. Let's define my list such that ...
4
votes
2answers
108 views

`IntegerPartitions` without duplicates

I need to apply a function to integer partitions of many integers, but only the partitions without duplicate numbers. Select[IntegerPartitions[n], DuplicateFreeQ] ...
0
votes
2answers
63 views

How to prove that an equation can be divided by any n?

I'm new to Mathematica and came across with the problem. I can't prove that (for example) 2*n is always even no matter what n ...
0
votes
1answer
91 views

How to turn a subroutine into a function?

I've written a subroutine that takes in 6 matrices and after some manipulation returns back 3 new ones. I will use this subroutine fairly often in this notebook so I think it would be easier to turn ...
-1
votes
1answer
46 views

How to graph the max and min values of a sheet?

Hi I just start working in Mathematica version 10.3.1 and I want to graph a sheet of data that I created in Excel (yeah i use Windows). The problem is i have so many data; 200 columns and 50 row of ...
11
votes
2answers
420 views

How to fill a grid make its total be largest

I have a blank grid whose dimension is 5*5. I want to fill it with some number using 1, 2, 3 and 4. But in every blank space if you fill 2, its neighbor (include four direction, such as left, ...
-1
votes
1answer
45 views

Generate list of first 100 prime number? [closed]

I know how to generate a list of prime numbers up to a limit, but how would I generate the first 100 prime numbers in a list?
3
votes
2answers
101 views

Using “Outer” with “ChineseRemainder”?

I'm looking to build a $7\times3$ matrix using ChineseRemainder. Trying to use ${0,1,2,3,4,5,6} \pmod 7$ and ${3,15,21} \pmod {30}$ so that the first element of ...
4
votes
3answers
130 views

Replicate sublist in new list

If I have a list of lists $a$ and a list of occurrences of each sublist $n$ a={ {1,1,1}, {2,2,2}, {3,3,3} } n={1,3,2} what is the most efficient way to get the ...
3
votes
2answers
70 views

Calculate Cumulative Mean and Standard Deviation of a list without FOR loops [duplicate]

I have a simple list mylist={x_1,x_2,...,x_N};. Now I want to map a function over this list, e.g. the Mean and StandardDeviation functions, so that it will give me ...
5
votes
3answers
123 views

How to partition a set with a condition on subsets?

I want to partition a set of $n$ elements into $k$ subsets with a condition For example: partitioning this set {1,...,5} into 3 subsets with this condition: if $|i-j|<d$ then $i$ can't be with $j$ ...
16
votes
3answers
440 views

How to group and join points

It seems there are many similar questions on Mathematica.SE, but none addresses (to the best of google) exactly my problem. I have the following data: ...
0
votes
1answer
54 views

Append[] is not working for empty list [duplicate]

I am trying to create an empty list and add an element but the list is not being populated. My code ...
0
votes
0answers
40 views

Do[If[ *stuff* ]*arguments*]: Increasing range over which Do iterates changes results of If?

Summary: If I run the same Do[] expression but with the variable(s) over which I am iterating taking on more values (but same increment), an If statement inside the Do[] evaluates as false a few times ...
26
votes
6answers
4k views

How to Delete Elements from List1 appearing in List2?

I'm new to functional programming of Mathematica and trying to remove one list of assorted elements from another. However I only find functions working with the Index rather than the values itself: ...
0
votes
1answer
41 views

Help with limiting output

I wrote this program on Mathematica (which I am very new to): ...
11
votes
4answers
484 views

How do I extract a matrix of only positive numbers given a set of assumptions?

I want to divide a matrix: mat = {{a, 0, -b}, {d, a, 0}, {0, 0, -a}} with the following assumptions: ...
10
votes
4answers
268 views

Convert elements of list to string

how easily can I convert elements of this list to string. If I have output like this: {{M, 1, 0, 0, 1, 1, 1, 0}, {A, 0, 0, 0}} And I want something like this: ...