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

learn more… | top users | synonyms (3)

4
votes
2answers
172 views

How to only work on sublists with non-zero (or positive) values

i have a large compositional dataset which contains non-zero and zero values. here is a sample: ...
3
votes
7answers
414 views

Remove elements at certain positions from all sub-lists?

Consider a big list where all the inner lists length's are the same list = {{x1, y1, z1, t1}, {x2, y2, z2, t2}, {x3, y3, z3, t3}, ...}; elementNo = {4, 3, 2}; ...
6
votes
2answers
604 views

Select elements of list within a date range

I have a list which consists of elements each of which has a date in DateList format, a number and a flag (Y/N). e.g. ...
14
votes
10answers
1k views

Pretty way to group elements at odd and even positions

How to make a function that splits list elements by odd and even positions? Shortest implementation wins. I myself came up with: ...
1
vote
1answer
63 views

PrependTo fails on a Table of Evaluated funtions

My task is something like this: PrependTo[Evaluate[Table[{x, Sin[x]}, {x, 0.1, 2 \[Pi], 0.1}], {0., 1.}]] where I tried also skipping the ...
14
votes
1answer
213 views

Ordering function with recognition of duplicates

Fairly often I have a need to get the Ordering of an expression but with recognition of duplicates. For example: ...
27
votes
5answers
2k views

How to efficiently find positions of duplicates?

Is there an efficient way to find the positions of the duplicates in a list? I would like the positions grouped according to duplicated elements. For instance, given ...
3
votes
2answers
671 views

For loop with steps other than 1

I would like to do a For loop with a jump 2*Pi instead of 1. For[j = 0, j <= nmax, (incr = 2 Pi), ...] Actually what I want to do is ...
11
votes
3answers
1k views

What is Mathematica's equivalent to MATLAB's filter function?

The MATLAB code filter(0.5,[1, -0.5], [1:10]) is equivalent to Rest@FoldList[(#1 + #2)/2. &, 0, Range[10]] I don't ...
2
votes
1answer
181 views

Replace a specified portion of an array with elements from another smaller array

This may be a trivial question, but I have been at it for a couple of hours and I have not made much progress. I have a 10 x 10 array (T) that I have used to generate an 8 x 8 array (Q). I want to ...
2
votes
1answer
230 views

Extracting information from list

I have a huge list that looks like this: ...
12
votes
9answers
464 views

Dropping n consecutive terms from a list periodically

Suppose I have the following list lis = Range[100]; and I want to remove n consecutive terms periodically from the list. For example suppose I want to drop terms ...
7
votes
4answers
618 views

How make f[{x,y}] evaluate as f[x,y]?

I frequently encounter the situation where I have a function of two real variables defined, e.g.: f[x_, y_] := 9 - x^2 - y^2 But then I need to feed into ...
3
votes
4answers
751 views

Extract function arguments

Is there a way to extract the arguments of a function? Consider the following example: I have this sum ...
0
votes
3answers
173 views

How to construct pairs in a list?

I have an expression like this, input = x[1] x[2]^3 x[5]^2; Fist step, we can get a list from the input expression, ...
1
vote
2answers
365 views

Select rows from table by keys

I am looking for a way to iteratively select all sublists with the same ID (my 1st column, residual columns are AbsoluteTime entries). First, I obtained the list of ...
0
votes
0answers
38 views

Correspondence between eigenvectors and eigenvalues [duplicate]

Let us say I have a matrix h (2x2). Now, I want to get the eigenvectors and eigenvalues of my matrix h: ...
4
votes
3answers
476 views

Separating positive and negative numbers into two arrays

$c$ is a vector with real numbers.I want to separate the positive ones and the negative ones into two vectors: $a$ and $b$. I have the following problem: When I do: ...
4
votes
4answers
1k views

How can I make the Cartesian product of a list with itself? [duplicate]

I'm trying to build the table {{1, 1}, {1, 2}, {2, 1}, {2, 2}} given the list {1, 2} I can do it like this ...
1
vote
2answers
1k views

Finding a best fit curve and plotting it [closed]

I have a list as shown below: m01 = {{250, 0.083121}, {200, 0.0888446}, {150, 0.0992422}, {100, 0.121567}, {50, 0.186825}} I'm new to Mathematica, and would like ...
0
votes
1answer
94 views

Collecting roots of different equations and create a list

I solve two equations and have two solutions one by each equation. I want to create list of these roots. Could anyone please help me? Appreciate it. m02R150 = FindRoot[P1 == 0, {E1, 0.07, 0.1}] ...
8
votes
1answer
311 views

How to remove some elements in a list based on a rule?

I want to deal with the following list. mylist = Table[cof[i] exp[i], {i, 1, n}]; (*n is very larege *) exp[ ] is a function ...
4
votes
2answers
218 views

Extracting data from a table under conditions

I have a very large table with two columns. Let's say the name of first column is E and the name of the second is P. How can I get the E values when P = 0.
1
vote
1answer
88 views

Calibrating Precision in calculations

As the title says, I encounter an irritating problem which has to do with the accuracy or the precision used in the calculations. To be more specific, I have the following code: ...
4
votes
1answer
340 views

A Faster way to combine two Lists of different structures into one of a different structure [duplicate]

I have the following two lists (each containing over 500,000 elements). Here is a sample: ...
1
vote
0answers
144 views

Transferring a list from one notebook to another [duplicate]

I have Mathematica code split into two notebooks. The first part is supposed to run and output a list of numbers into a text file, using Export. The second part ...
3
votes
1answer
142 views

How can I get a single solution to a set of inequality constraints?

I have a set of constraints to which I require integer solutions. However, instead of needing all possible integer solutions (as obtained by using ...
5
votes
1answer
316 views

Problem with creating a large list of tuples

This is a follow-up question from Sum of Multinomial Coefficients I have thought about the meaning of the formula I mentioned and, with help, I implemented the following code: ...
6
votes
2answers
545 views

Merging two Lists

I have two tables. One is given by T1 = Table[{x, y, 0.}, {x, 0, V},{y, 0, V}] and from a calculation I have the second, a list of points {x, y, z} ...
6
votes
3answers
172 views

How to 'merge' a list like FromDigits, but with a mixture of numbers and symbols?

How do I go from {C,4,G,5,S,7} to C4G5S7
3
votes
4answers
318 views

Mapping over the last level of a list, or equivalent operations

I would like to style each element of my list using Style. But when I try ...
10
votes
7answers
616 views

How can I Flatten this List with Inner List of Lists?

Given the following List ...
7
votes
2answers
2k views

Get the coordinates from ContourPlot and RegionPlot

How do I get the coordinates from a contour plot I've done in Mathematica? For example, I have a two-variable function f[x, y], for which I can make a contour plot: ...
-1
votes
1answer
102 views

How to separate a vector into two vectors, one having the first half of my original vector and the other having the second half

I have a set of n vectors with an even length. Let us make an easy example with 3 vectors of length=4: ...
2
votes
1answer
836 views

How to solve equations self-consistently

I want to solve the following equation self-consistently. So, H.u = e.u {{1, d}, {d, 1}}.{u1, u2} = e.{u1, u2} I guess an initial value for ...
16
votes
1answer
4k views

How to remove redundant {} from a nested list of lists?

There are numerous examples here, whose end result is the removal of empty brackets {} and empty lists. I still can't find an example of simply removing redundant ...
1
vote
3answers
189 views

Separate an array in two arrays, the even and odd terms being separated in these two arrays

How can I separate the odd terms in one array and the even terms in another array,i.e., go from a={1,2,3,4} to aeven={2,4} ...
1
vote
2answers
190 views

Subtract more than one array using DeleteCases

I need to create an array subtracting two arrays from another array. I know how to subtract one: am = DeleteCases[amp, Alternatives @@ af] I can subtract an ...
0
votes
1answer
72 views

How to get a number, but not a list, of the dimension of your array?

I need to use the dimension of a certain array, to use it as a bounder in a loop afterwards. The problem is that I get a list, when write : ...
-2
votes
1answer
295 views

Non-regular grid data

I have issue with non-regulary spaced data. I have set of 3 numbers {x, y, z} in my list. ...
1
vote
3answers
1k views

Loop through a list and select elements

I am new to Mathematica and I have no idea how to make a basic for loop work. I want to loop through the elements of a list: Range[45, 200]. I want to select the ...
3
votes
5answers
467 views

How to combine some elements of a list?

In order to simplify my expression, I face a list manipulation problem. For example, given the input list ...
2
votes
3answers
496 views

Selecting subsets of a list containing a specific element

I'm trying to generate all the subsets of a set containing a specific element. For example, for the set {1, 2, 3, 4}, with the specific element I want inside each subset being 4, the required answer ...
4
votes
5answers
139 views

Convert a list with three arguments {x0,x1, step} into an equidistant table?

How can I convert a list such as: a = {1, 2, 0.1} into sequence so that I can pass them into a function, e.g. I want to be able to do something like this ...
8
votes
3answers
445 views

Multiply a list of matrices by a list of vectors

How does one multiply a list of matrices by a list of vectors, elementwise? For example, multiplying ...
3
votes
2answers
166 views

Sequence and boolean And

I'm trying to figure out if a calculation result it's a valid result. As it return a matrix, I need to test that every element it's a number, so I thought this could work... ...
9
votes
1answer
217 views

Creating a number based on given conditions

In the grade 7 math curriculum here in Alberta we teach divisibility. I'm trying to write a program to create questions based on the idea of a student being given say, 4 digits, and then choosing ...
8
votes
4answers
503 views

Find list position and mapping list

Sorry, my English is not very good. I have two lists: ...
9
votes
2answers
328 views

Speed up 4D matrix/array generation

I have to fill a 4D array, whose entries are $\mathrm{sinc}\left[j(a-b)^2+j(c-d)^2-\phi\right]$ for a fixed value of $\phi$ (normally -15) and a fixed value of $j$ (normally about 0.00005). The way ...