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

learn more… | top users | synonyms (4)

2
votes
1answer
110 views

Why is there a difference when formulating patterns for Select and FirstPosition?

Select[{1, 2, 4, 7, 6, 2}, # > 2 &] Gives {4, 7, 6}. OK! So one should think that the following would work: ...
2
votes
0answers
31 views

Basic Question: Split Nested list into respective elements [closed]

New to Mathematica, just have a very basic question to ask. I have a table of results like so: ...
2
votes
3answers
121 views

Given a list of triangle vertices, how to find the neighbors for each vertex?

A triangle is represented by {a,b,c}, indicting that its vertex IDs are a, b, and ...
1
vote
5answers
128 views

Select using MemberQ

I want to make a selection on this list ...
0
votes
2answers
62 views

Company headquarters for each cell in a spreadsheet

I have an Excel spreadsheet column with hundreds of company names on it. I need to find the address (or just city if that's easier) The operation for this is simple in wolfram alpha. i.e. typing ...
3
votes
6answers
562 views

How to smooth the noise

This is a sample data ...
0
votes
1answer
29 views

Creating a custom list [closed]

This is the first list lts1 = Table[i, {i, -1.8, 5.8, 0.1}] 1st question: In the interval between -1.8 and 5,8 how can I choose the step beforehand so as the ...
2
votes
3answers
66 views

An extra { when importing a file [closed]

I am trying to import data from a file. {k0,{a0,b0,c0},{e0,f0,g0}} {k1,{a1,b1,c1},{e1,f1,g1}} MyList = Import[file, "Data"]; But I get a list with an extra "{" ...
9
votes
5answers
251 views

Find all the possible ways of partitioning a list into a set of pairs of element

I have a list {x1,...,xN} where N is even, and I need to find all the possible ways to split it into pairs of elements, e.g. the ...
7
votes
1answer
103 views

How to select a submatrix containing similar elements from a matrix? [closed]

( This question is related but does not ( fully ) answer my questions. - Finding the position of similar elements in a matrix ) I have not written code yet, I am in the design phase of code for the ...
3
votes
2answers
80 views

Output matrix with common elements

Given lists of lists like a and b, I want to obtain an output like c. a = {{2, 1, 0}, {1, 2, 1}}; b = {{2, 2, 0}, { 2, 2, 1}}; c = {{2, 0, 0}, {0, 2, 1}} If ...
0
votes
1answer
58 views

Applying corresponding elements of a list to a list of functions

I found this post which applying a function to a list of functions and arguments. I thought I could change my code with a table to something more elegant. I am not wedded to the ...
0
votes
3answers
75 views

Confusing “Part::pspec” and “Part::partw” following call to ParametricPlot3D

The problem I'm having is that the function definition given below continually gives me baffling error messages. I'm trying to turn a list of 3D points into a function that approximates a curve by ...
2
votes
1answer
77 views

Using and replacing sequential elements of a list

Very simple question but I am an absolute beginner, so apologies if this has already been answered. I need to pick sequential elements of a list, excluding t=1 and t=T, and use them in a function. ...
6
votes
3answers
179 views

On a strange pattern of triangular numbers in Ulam's spiral

In this MSE post, user GeMir noticed that, where the green dots are the triangular numbers, $$T_n = \frac{n(n+1)}{2} = 1,3,6,10,15,21,28,36,45,55,66,78,91,105,120,136,\dots$$ in the Ulam spiral ...
3
votes
1answer
60 views

Count two or more equal consecutive elements in a list and create histogram

I have a list generated by: list = RandomInteger[{1}, 100] it contains only 0's and 1's ...
1
vote
4answers
94 views

GatherBy output with given Shape

I would like to group items in a binary list according to some property like in the following simple example. ...
1
vote
0answers
48 views

Apply ListPlot to various data sets [duplicate]

Assume that I have data in the form: list = {{{1, 2, 3}, {10, 10, 10}}, {{4, 5, 6}, {20, 20, 20}}} I want to plot ...
3
votes
1answer
49 views

Remove cases where region specified incorrrectly

I am using MeshPrimitives to get a list of 3D components of a Mesh Region. Within that list, I normally get some incorrectly specified regions, such as ...
1
vote
2answers
62 views

Combining data sets by adding y values [duplicate]

Suppose I have the following list of data {{1,2},{1,5},{6,1},{1,3},{2,1},{2,2},{2,3},{5,4},{5,2}} This is similar to my actual data in that each x value has ...
2
votes
3answers
112 views

Positions of elements in a list [duplicate]

I have two lists: list = {1, 2, 3, 4, 5} slist = {3, 5} I want to find the positions of the elements in slist in list. I tried it like this and I dont understand ...
4
votes
3answers
263 views

Efficiently test membership for a list of values

I have two lists: excluded and values. I would like to efficiently determine whether ...
6
votes
2answers
236 views

What is the idiomatic way to shift and extend a list by a number of elements?

I have a lists, list, and want shift it right by a given number of elements, m, extending the list by repeating the last ...
4
votes
2answers
69 views

How to delete blank valued keys from nested association?

Considering we have: acs = <|"A" -> <|"a" -> " ", "aa" -> "asd"|>, "B" -> <|"bb" -> " "|>|> How can we come to have a result ...
3
votes
2answers
71 views

Retaining relative sizes of local maxima using MaxDetect[List]

I would like to be able to find the position of the two greatest local maxima in a list. For the example: list={1,2,3,4,2,1,2,6,5,4,3,2,} I would like to return ...
4
votes
3answers
73 views

Replace values in a list based on conditions

I have a list with negative and positive numbers list = {-1, -2, 1, 2} and I want to replace all negative values with 0 and all positive values with 1 ...
2
votes
1answer
65 views

How do I define a random variable involving Part?

I need to define a random variable that involves Part, but when I try, for example ...
0
votes
1answer
74 views
16
votes
10answers
698 views

Count the sequences in an array

Is there a short and easier way to count number of sequences in a list? Let's say I have three lists: list1 = {0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0} ...
2
votes
2answers
38 views

Join data imported in different variables [closed]

I've imported data from Excel into several variables and I would like to join all data in one "big" variable. I seem to have a problem when one variable contains numerical data... ...
1
vote
2answers
83 views

Ask about the variable and constants in partial derivative in a loop

EDITED I have a function in a list like : func={2(x^2)+x*y+3(y^2)}; I want to have a UI that ask me which parameter (x or y) is a variable in a ...
0
votes
1answer
28 views

Transpose four lists of data into two lists for use in List Plot [closed]

I have four lists of data x1 = {1,3,5,7} y1 = {0,2,4,6} x2 = {10,12,14,16} y2 = {8,10,12,14} In one line is it possible to use transpose to get two lists which ...
0
votes
0answers
54 views

Switching ArcTan argument from a sequence to a list

The objective is to determine the angle formed by the line connecting two points in the plane, say p and q. The ...
4
votes
3answers
134 views

How to get multiplication of the elements of a specific list/Matrix

Assume there is a list: List1={a,b,c,d}; Then I want to get these calculation: ...
0
votes
2answers
34 views

How to get Complement function working in a For loop? [closed]

I've been working on a piece of code that will delete small components from a nested uneven matrix (n pages, n rows, 3 columns), by deleting the pages with less than ~30 rows. However, I've notice ...
4
votes
2answers
117 views

Initializing several values of a function

How do I initialize several values of a function at once? Consider the function f[0] := 1; f[1] := 2; f[2] := 3; f[n_] := f[n] = f[n-1] + f[n-2] + f[n-3]; Is ...
2
votes
4answers
167 views

Given a matrix of integer, create a matrix with 1 or 0 according to which numbers are in the first matrix

Not sure the title gives the idea of what I need, so here is a sample: I have ten (w) combinations (subsets) of 20 (n) numbers taken 4 (k) at time. I need a matrix of dimension w x n with 0/1 in each ...
0
votes
2answers
74 views

Write list of numbers to a file

I have a list of numbers: e.g. list={1,2,3,4,5} To write the list to a file I use (here each integer number occupies 7 spaces): ...
2
votes
2answers
97 views

How to remove multiplicities from for a list in way meeting special criteria

I have a list of pairs, tabul, which has the property that the second element of each pair is also an element in my list data. I ...
7
votes
4answers
211 views

How to Apply Functions to Lists with Many Curly Brackets?

For example, consider the list defined below. samplelist = {{{1,2,3,4}}, {{5,6,7,8}}}; How would I apply the Times operator ...
0
votes
0answers
30 views

FoldList[Union,…] version 8 vs version 9 [duplicate]

I have a list of matrices something like shown below A = {{{1,1,1,1,1},{2,2,2,2,2}},{{3,3,3,3,3},{4,4,4,4,4},{5,5,5,5,5}}} When I try to run the code ...
3
votes
1answer
60 views

Iteration variable in variable [duplicate]

Is it possible to create following list by some sort of iteration? {a1,a2,a3,...,a100} I cannot think of any way to append a to ...
3
votes
1answer
140 views

Union of two or more lists

I have a number of lists (only 3 shown here) ...
1
vote
0answers
42 views

Generate a list of values of a function for each value of the parameters already found

The following question is an extension of this question Find all roots of a function with parabolic cylinder functions in a range of the variable. Now I want to use the roots found to calculate a ...
1
vote
0answers
60 views

How to remove brackets from this list? [closed]

I have some lists which have many brackets. I'd like to remove brackets from the lists. For example, I need to change the list ...
2
votes
3answers
102 views

Efficient extraction of a subset

The context is molecular dynamics. The data is in the format (index_1, index_2, distance). The goal is to find all of the distances to the neighbors of point index_0 and to present a set listing the ...
7
votes
3answers
202 views

Merging lists of pairs [duplicate]

I want to add several fluorescence spectra. They are lists of the format ...
1
vote
2answers
137 views

Query in Lists Mathematica - Pivot table

Recently, I finished a simulation, and I got the following data: ...