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

learn more… | top users | synonyms (3)

10
votes
10answers
372 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
36 views

Join data imported in different variables [on hold]

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
74 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
23 views

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

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 ...
2
votes
1answer
499 views

How do I sort complex numbers?

Okay, so I posted something about sorting, and it was linked as a duplicate to This post However, I am having problems trying to sort a list that contains both real and complex numbers. I put them ...
4
votes
3answers
123 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: ...
3
votes
1answer
107 views

Map an Argument to a list of functions

I want to "map" an argument to a list of functions. Here is the concrete Problem. I generate a list "Messungfit" of functions: ...
0
votes
0answers
53 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 ...
0
votes
2answers
31 views

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

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
109 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
158 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
1answer
98 views

Appending elements to a list in parallel table

Is there any way to store values in a list that is being computed in parallel? For example, if ParallelTable is computing some ...
0
votes
2answers
69 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
131 views

Approximation of definite integral by parabolas

This question is related to Trapezoid approximation to definite integral. As promised, I am now asking about how to draw approximation of integrals by parabolas. I tried to modify MarcoB's code, and I ...
0
votes
0answers
14 views

Selecting elements from list based on list of positions [on hold]

I have a list with elements I want to select: list = {1, 34, 98, 4, 5} Now I want to select elements of those list based on a list with positions like: ...
7
votes
4answers
187 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 ...
2
votes
2answers
92 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 ...
0
votes
1answer
73 views

Elements inside arrays seem to be strings rather than signed numbers

When I have code like b = Array[Subscript[be, #] &, {3, 1}] b = b /. {Subscript[be, k_] :> Subscript[-be, k] /; k > 1} I am noticing that Mathematica ...
3
votes
1answer
135 views

Union of two or more lists

I have a number of lists (only 3 shown here) ...
0
votes
0answers
27 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 ...
-1
votes
0answers
45 views

Building Pythonic Programming style to Mathematica with visually-accessible list comprehensions?

The question List comprehension in Mathematica has comment about this Functional style using lazy lists? where they build some sort of style for lazy lists: I understand it so that it is impossible to ...
2
votes
2answers
115 views

What is wrong with my use of Flatten? [duplicate]

Why does Flatten[f[g[a, f[b]], f[c, d]]] result in f[g[a, f[b]], c, d] I expected the answer to be ...
0
votes
2answers
290 views

Extract X value from corresponding Y value from a List or Transpose [duplicate]

I have a list of X values and Y values separately, and also together with: data=Transpose[{X,Y}] This data is from a chromatogram, and I want to extract the ...
2
votes
2answers
95 views

How can I get a certain kind of iteration?

Can I get this type of do-loop in Mathematica? Do[Print[j," ",k," ",l], {j,k,l, {a, b,z}, { c, d,y} }] I want this to work so that, in the first iteration, ...
3
votes
1answer
53 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 ...
2
votes
3answers
100 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 ...
0
votes
1answer
407 views

Generating all “from n choose k” configurations of a simple list [duplicate]

Suppose that I have a 1-D list called myList. Here's an example: myList = {"A", "B", "C", "D"}; I want to write (or find ...
1
vote
1answer
51 views

How to set the values into some variables from different lists [duplicate]

I have a list of Values and a list of variables. I want to set the Values into Variables. Assume the following code: ...
1
vote
0answers
36 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 ...
7
votes
1answer
113 views

Automatically grouping words into categories

Say I have a comma-separated list of words. For example sake, let it be things I have seen during my trip to a safari zone. It would look something like that: ...
1
vote
2answers
121 views

Query in Lists Mathematica - Pivot table

Recently, I finished a simulation, and I got the following data: ...
1
vote
0answers
43 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 ...
6
votes
3answers
187 views

Merging lists of pairs

I want to add several fluorescence spectra. They are lists of the format ...
4
votes
6answers
2k views

Removing zero values from ordered pairs

I have some processed data, which are basically a collection of ordered pairs in the form: {{x1, y1}, {x2, y2}, ..., {xn, yn}} Ordered pairs which have either a ...
1
vote
2answers
48 views

Formatting a table of values

How do I display a list of values $\{a_1,a_2,\ldots,a_n\}$ in a two column format? --------- 1 | a_1 2 | a_2 3 | a_3 ...... n | a_n I tried ...
3
votes
5answers
121 views

How to filter list of list of rules on certain condition?

For example, Solve[] returns all solutions as a list of list of rules. And mine looks something like this: ...
10
votes
3answers
352 views

Modifying strings in a list efficiently

I have a list of strings $\{s_1,s_2,\ldots,s_n\}$. I would like to to produce the following list of strings: $$ \{s_1<>1,\ 1<>s_2<>1,\ldots,\ 1<>s_n\} $$ In other words, I want ...
10
votes
3answers
363 views

Riffle and Partition

At some point I noticed that I was using Riffle and Partition together a lot. I would do things like ...
18
votes
9answers
2k views

Selecting a sublist based on Length

If you have a simple list of lists as follows: test = {{1, 2}, {4, 5, 6, 7}, {5, 4, 3}} How do you ask Mathematica to return the sublist of greatest length? ...
5
votes
4answers
137 views

Create Nested List from tabular data

Im trying to create a nested list from tabular data, then onward into a nested association. I can get part way with the help of this answer but it only works for the first level. Repeated use of this ...
18
votes
7answers
8k views

Mathematica: finding min/max in list

I have a list of coordinates like this one: {{x1,y1},{x2,y2},{x3,y3},...,{xn,yn}} I need to get the minimum and the maximum of all x-values and the minimum and ...
3
votes
0answers
74 views

speed up evaluating a listable function

I apologize in advance for the vagueness, but I can't think of a more descriptive title. I am trying to find the average value of the square of BesselJ[0, x] ...
13
votes
4answers
335 views

I have the minimum Y value. I want to find the corresponding X value from the list [duplicate]

I have a very big file and contains data in the format of {x,y}. I got the minimum Y value by using data[[All, 2]] // Min[#] & Now I want to get the X value ...
2
votes
1answer
44 views

Defining a function which takes lists as it arguments and threads over them [closed]

I want to define a function with lists as variables, which has the form like m = Table[2, {i, 5}]; f[x_, y_] = m*x + x*y; x and y are list variables; m is a ...
23
votes
3answers
1k views

Using pure functions in Table

I need a table with the elements made of pure functions and list elements. This is a simplified example: I need a list as: ...
1
vote
2answers
57 views

Using Apply on a function with multidimensional input

I have a user defined function which takes multidimensional input, e.g a function that takes two algebraic variables a and b as well as a matrix m and computes some rule function as: ...
2
votes
3answers
168 views

Delete rows based on specific periods

I have data (.xlsx format): two columns - data in first column imported as DateObject (dates with specific time), data in second column are numbers (113388.28, 865165.98 etc.). I want to delete the ...