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

learn more… | top users | synonyms (3)

12
votes
5answers
279 views

Can ReplacePart be sped up?

Test case: ...
10
votes
5answers
486 views

How to find first list element that differs from average of N previous elements by more than a given amount?

Given a list of real numbers, I need to write a function that returns the value of the first element in the list that differs from the mean of the previous $N$ elements by greater than $P$ standard ...
5
votes
1answer
184 views

Selecting a list from a list of lists

In working through Programming Paradigms Via Mathematica (A First Course) I have come across this two part question: A permutation of length "n" is a list of the first n positive integers in ...
10
votes
5answers
682 views

How can I simulate this animation of checking for prime numbers?

I can only implement a very simple one, I want to make my code look like that. Any better ideas? ...
2
votes
2answers
203 views

Deleting parts of groups that do not have equal dates

Find the intersection of dates within the pair and remove the other dates & corresponding prices. Also keep the list in same format as it currently is in. Let me explain: Each stock has closing ...
2
votes
3answers
301 views

Select sublists with second element nearest to zero

I've got some big lists from which i need some data (one of the big lists). To be specific, I need to divide this biglists in sublists of the same length (10000), and form a new list with the mean of ...
15
votes
3answers
535 views

How to partition a list to make each subset's size equal and mean as close as possible

Suppose we have 3 lists each with 18 numbers like this: ...
0
votes
0answers
58 views

Partitioning a list by specifying the lengths of the sublists [duplicate]

Suppose that I have an ordinary, one-dimensional, fully flattened List of expressions. Here is an example, a List called list: ...
8
votes
10answers
337 views
1
vote
1answer
124 views

Extracting lists from list based on length

I have a list looking like this; ...
0
votes
1answer
108 views

Using sublists returned from a function as elements of a list argument to an other function

This is a contrived example, but it gets the point across. I am looking to use the following as inputs: ...
16
votes
12answers
1k views

Pick elements of largest absolute value

For example, given list = {{1, -3, -5}, {2, 1, 6}, {0, 2, 4}, {-9, 2, 6}} should return: {-5, 6, 4, -9} Updated I found ...
4
votes
0answers
161 views

Replacing and combining elements in a list [duplicate]

I am trying to increase the level of nesting in the following list while adding a 'tag' to each leaf: ...
1
vote
0answers
34 views

How to divide all rows of a matrix by their row sums [duplicate]

I've got a general matrix K that I would like to divide it's row's by the row sums of the matrix. I could get this going by doing ...
5
votes
2answers
356 views

How to combine elements of two matrices?

Given two matrices m1 and m2, e.g.: m1 = {{a1, b1}, {c1, d1}} m2 = {{a2, b2}, {c2, d2}} How can one obtain the following? ...
0
votes
2answers
132 views

List manipulation - End loop

Given are two matrices (a & b). I want to end the For-loop if all values in the matrix (a minus b) are smaller than 7, in contrast to any value in the matrix (a minus b) is smaller than 7. Can ...
2
votes
1answer
290 views

Extracting a range of data from a table

I have text file with data in 2 columns. I have imported it using the following line c = Import["ab", "Table"]; This text file has a large amount of data, and I ...
1
vote
1answer
186 views

Map a function conditional on elements at multiple relative positions in a list

I figure this question has many solutions, and if an answer already exists it would be nice just to be referred to it. I need a function that 'maps' over my list and produces a list of equal length ...
4
votes
2answers
195 views

Can someone explain this code for joining two lists by the first element of each sublist?

Background (which may be skipped, unless context is needed) I've recently begun learning Mathematica (and only up to chapter 3 of Wellin), but wanted to write some code to get a better feel for ...
1
vote
1answer
75 views

Create a new list under conditions from an existing one

I have an external file (data.out) which I read it with Mathematica using data = ReadList["data.out", Number, RecordLists -> True]; This file contains three ...
8
votes
3answers
191 views

Select and Blank

I try to filter sublists of a list which match a pattern. test = {{"String1", "a"}, {"String2", "b"}, {"String3", "a"}, {"String4", "a"}}; The result should ...
4
votes
4answers
161 views

Robust function for manipulation of nested lists

I have a nested list of the form: ...
2
votes
1answer
144 views

How to compute a discrete histogram of a list [duplicate]

I'm trying to compute the discrete histogram of a set of values. By histogram I mean the absolute frequency a value appears on the dataset, by discrete I mean the values are from a discrete set, e.g. ...
0
votes
1answer
118 views

Reuse a dynamic list [duplicate]

Consider this Dynamic list ...
1
vote
3answers
184 views

Creating overlapped block matrices

I'm doing an FEM assignment using Mathematica. (EK1 = {{a11, a12}, {a21, a22}}) // MatrixForm (EK2 = {{b22, b23}, {b32, b33}}) // MatrixForm I don't know how ...
6
votes
3answers
1k views

Simulate MATLAB's meshgrid function

Here is MATLAB's meshgrid. I came up with these implementations in Mathematica: ...
1
vote
2answers
254 views

How do I create matrices with arbitrary list restrictions?

I want to randomly generate a square matrix of dimension n with entries in the list StartingEntries, and also satisfying that for any such matrix M, the matrix Inverse[IdentityMatrix[n] - M] has ...
8
votes
3answers
182 views

Preserve information in flattening a nested list

I have a series of lists in the form below: list={ {1,1} , {2,2}, {3,{3,1},{3,2},{31,{31,1},{32,2}}} } Its a nested list which the dimension is changing case to ...
4
votes
4answers
239 views

Elegant Matrix Combinations

Suppose you have a matrix (mxn), simplified for illustration m= {{a, b, c}, {d, e, f}} And a set of combinations (simplified for illustration purposes but can ...
0
votes
2answers
137 views

Compute percentages in a list

I have a data file which contains thousands of lines and each line has eight elements. Here is a small sample of the data file ...
1
vote
1answer
187 views

ListPlot under conditions Part II

I have a data file containing several columns and thousands lines of data. Below I present a small portion of it, in order to express my issue: ...
4
votes
4answers
238 views

Generate Non-Singular Matrix of $n*n$ dimension

I want to create a function that will make an $n*n$ matrix which is non-singular that will always retrieve the same matrix (meaning that the matrix will not be random each time). I tried using the ...
12
votes
5answers
456 views

Filtering elements from a list that appear only once

I want to be able to select elements from a list that only appear once. I originally had this: Select[Table[Count[list, i], {i, list}], # == 1] But the issue is ...
2
votes
1answer
125 views

Match a sequence of integers

I would to match a pattern p1 = 0,0,1,0,0 to the elements in listA. The elements are a boolean sequence that may look like this ...
-1
votes
2answers
86 views

Manipulate store values

Is there a way to store the numerical values from a manipulate function in the form of a table? For example, if the function is f[x_] := x^2 - 2x Can one store ...
1
vote
2answers
131 views

Creating a Table of Items for GIF creation

I want to create a table as shown below so that the steps from the first item to the second item, and the second item to the third item, etc. can be animated. I am not at liberty to post tested ...
1
vote
1answer
98 views

How can I make check boxes that put elements into a list?

Right now I have a blank list that I am putting in Manipulate[]. I want to be able to choose whether 1,2, or 3 are in this list by setting z1,z2, z3 as True or False: ...
14
votes
4answers
446 views

“Unflattening” a list

Imagine we have a list with some hierarchical structure: list = {{{2,3},{2,4}},{{{3,4}}},{{5,6},{7,8}}}; Which we then flatten to some level in order to process ...
3
votes
8answers
250 views

How Do I Perform Simple Operations On The Elements of a Table?

I have been using the function HistogramList to generate frequency tables off a data set. The code looks like this: ...
9
votes
5answers
337 views

Count consecutive occurrences in a list above a certain value

I am trying to tally and sort the number of consecutive occurrences in a list above a certain value. For instance: ...
1
vote
1answer
145 views

Create continuous function from list

I have a list of data (measured per day) that I want to use as imput for another equation (say f). The problem is that the input I need for f needs to be a continuous function of time. Is it possible ...
18
votes
7answers
814 views

Make a huge vector in a wise way

I need to construct a vector similar to: v[x_]:={0, 0, x, 0, 0, 2*x, 0, 0, 3*x, ....., 0, 0, n*x}; where n=10^9. How can I ...
17
votes
1answer
347 views

Underlying Algorithms for List Manipulation Functions

Does anyone know, or know of a link for the underlying algorithms used for list manipulation functions? Specifically: Union with and without the ...
8
votes
3answers
654 views

Checking for duplicates in sublists

I have a list with contains entries that are length 8 sublists,i.e. L1={{a1,b1,c1,d1,A1,B1,C1,D1},{a2,b2,c2,d2,A2,B2,C2,D2},...} and so on. Now, in my problem two ...
8
votes
6answers
210 views

Custom Matrix product

I have a list: list1 = {{{a1, a2, a3}, {b1, b2, b3}}, {{c1, c2, c3}, {d1, d2, d3}}}; I want an operation that gives me: Is there a built-in way of doing ...
5
votes
3answers
232 views

Drawing CountryData groups

I'm sure I'm overlooking something obvious, but I can't draw groups of countries. Here are two countries and two country groups: ...
5
votes
8answers
348 views

Extracting matrix rows when one of its elements is part of a list (without a loop)

I have a matrix whose rows I want to extract based on whether the elements of one of its columns is a member of another vector (calling it the "comparison vector"). I would like to get better at ...
0
votes
0answers
63 views

Defining functions in a loop [duplicate]

I have a symbolic solution to a linear system with respect to some variables a[i,j] which depend on a parameter t. sol=Solve[...,Table[a[i,j],{i,0,n},{j,0,n}]] I ...
3
votes
2answers
91 views

Linear interpolation of a list between periodic anchorpoints

I have a list of the form: list = {1,1,1,2,2,2,3,3,3,4,4,4,7,7,7,19,19,19}; Where we can see that there are an ordered set of integer values that repeat ...
2
votes
1answer
112 views

How to make a list/matrix out of an expression?

I would like to make a matrix out out of the following expression: $$ (\Omega^2 (2 d\theta^2 + d\phi^2 - d\phi^2 \cos(2 \theta) \coth(\chi)^2) + (2 d\Omega^2 + (2 d\theta^2 + d\phi^2 - 2 ...