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

learn more… | top users | synonyms (3)

2
votes
3answers
2k views

How to convert output of a For loop into a list

I have written a For loop in my Mathematica notebook. This For loop, when activated, will generate a sequence something like: ...
2
votes
3answers
310 views

How to transpose unequal lists

As the titel says I want to transpose a matrix containing rows of unequal length, to be able to transport them to excel (in row form, there are too many datapoint to write them in a cell. In another ...
2
votes
2answers
249 views

Position function not always retuning an answer even with no apparent problems

I'm having some problems with Position. Sometimes it will give an empty list instead of the actual position of the element I am looking for when that element is ...
2
votes
3answers
190 views

Rearrangement of the list

I have the following list: ...
2
votes
3answers
187 views

appending element to sub list [duplicate]

I have a list of the form: lstA = { { {"a","b"}, -1.5}, { {"c","d"}, -2 } } I wanto to add another value to each sublist that ...
2
votes
3answers
293 views

Re-arranging / selecting of a data table very slow in For loop [duplicate]

My task is quite simple; I have a table of data like M = {{1,2}, {1,3}, {3,4}, {5,1}, {6,9}, {6,8}, {6,1}}; so the table is sorted with respect to the first ...
2
votes
7answers
322 views

How to replace plus sign by comma

I want to replace plus by comma and the order of numbers in the list should be in increasing order. Example: a1 + a10 + a11 + a13 + a2 + a27 + a28 In this ...
2
votes
4answers
207 views

Removing coefficients and repeated elements

I got to a problem where as I just can't find the proper Mathematica command. I'm given a list, for example: $\{1,x1,-x1,x2,x5,x3,-x2,-x4\}$ I need this to become $\{1,x1,x2,x3,x4,x5\}$ The ...
2
votes
3answers
492 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 ...
2
votes
3answers
185 views

Alternatives to Append/AppendTo for generating a list in an interactive DynamicModule?

I have a stack of timelapse microscopy images that I am trying to segment frame-by-frame using some of Mathematica's image processing functions. I have created a little interactive DynamicModule with ...
2
votes
4answers
705 views

List manipulation: position & max value combination

Starting with {{0, 0, 0}, {1, 1, 2}, {2, 3, 3}, {3, 4, 5}} I would like to get {{0, 2, 3, 5}, {1, 3, 2, 3}} where the ...
2
votes
4answers
681 views

ListPlot multiple datasets over same x-values

Is there a better way to enter my data into a list plot? ...
2
votes
2answers
153 views

Comparing elements of the $n^{\text{th}}$ sublist in a ragged list with the $n^{\text{th}}$ member of a sequence

I have a list of lists that are not of the same length (for example, {{6}, {14}, {6, 26, 30}}), but I have to compare every element in the $n^{\text{th}}$ sublist ...
2
votes
3answers
612 views

Recursive function on list

Please consider the following: I have to deliver the weekly customer demand data on time. I can start to produce my products one week in advance. So I was thinking ...
2
votes
4answers
149 views

How to remove hours, minutes, seconds from list

How to remove 0 that represent hours, minutes, and seconds from a date list say a ...
2
votes
2answers
149 views

How to get the current index during a Scan iteration?

Is there a special keyword to get the current index in Scan ? For example, let say I have the following code : ...
2
votes
3answers
147 views

How to display the indices/element positions of a ragged array?

I have a three-level ragged array like so: ...
2
votes
2answers
102 views

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

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 ...
2
votes
3answers
184 views

Using Part rather than Extract

In my work I found that I needed the Extract function. However I was wondering if there was a way to use Part. Assume that ...
2
votes
2answers
544 views

Index-based Array splitting

I have an array of arbitrary elements, say strings: testArray = {"String A", "String B", "String C", "String D", "String E"}; How can I split this into two ...
2
votes
3answers
167 views

Extracing information from a table

I am new to Mathematica. I have created a table of real numbers. I want to create a new table that contains the set of values of $i$ such that, in my original table, the $i$th entry is greater than ...
2
votes
5answers
195 views

How do I find the maximum value from the given set of data?

I have a set of data like {{x1, y1},{x2, y2}, ...,{xn, yn}}. From this data can I find the value of x for which ...
2
votes
4answers
1k views

How can I create a list of functions?

Can anyone tell me, how to create a list of functions? I've tried the following code, but it doesn't work. ...
2
votes
2answers
119 views

Can you form a list with elements which are terms from an equation?

Is there a command that takes an equation as an input and creates an output with a list of terms in the original equation? Something like: ...
2
votes
2answers
341 views

Preparing data for making an ErrorListPlot

I often have the following notebook in Mathematica, which I use to make a dataset and associated errors: ...
2
votes
4answers
321 views

plot data differences

I have the following data: ...
2
votes
5answers
716 views

Assigning a particular value to array elements

I have an array of 10000 elements. I want to randomly assign energy to these 10000 elements using Gaussian or Exponential distribution, such that each time a particular element is selected its energy ...
2
votes
3answers
156 views

Splitting a list of lists (part2)

This is a follow up from Splitting a list of lists . What would be a nice way to split the list l1 = {1,2,{a,b,c},3,{d,e}} into ...
2
votes
2answers
91 views

Componentwise Addition of TemporalData

I'm a little confused with the TemporalData structure in Mathematica, in the sense that it doesn't seem to behave like a list. What I'd like to do is plot the sum ...
2
votes
2answers
227 views

Replacing values above a threshold with 1 [duplicate]

I have a list with some values and I want to replace a value which is greater than 1 with 1 otherwise keep the value. In this case 10562: ...
2
votes
4answers
112 views

Use a categorical argument to add one layer of list structure

Consider the following nested list x = {{1,2,a}, {3,4,a}, {8,11,b}, {12,3,a}, {4,3,b}, {3,2,c}} I want to use the categorical variable ...
2
votes
3answers
130 views

Concisely returning a position in an array with an index variable [closed]

We have an array and an index in the array: exampleArray = Table[{a, b, "q"}, {a, 1, 10}, {b, 1, 10}]; arrayIndex = {5, 4}; Very simply, we can return the value ...
2
votes
3answers
75 views

Take a list with the amounts of the random samples from another list while holding the index

I have a list called cant with some amounts of samples to take from the list community as follows: ...
2
votes
3answers
101 views

Table to text string [closed]

I know this is a simple question and there is a single command to do this but I have been looking for the command for 30+ minutes and cannot find it. I have a list that I want to put tabs between ...
2
votes
1answer
145 views

Multiple swapping of rows and columns

m={{a, b, c, p}, {d, e, f, x}, {g, h, k, z}, {u, v, w, y}}; I want to swap 1st and 2nd rows by 4th and 3rd rows respectively. And then, swap 1st and 2nd columns ...
2
votes
2answers
505 views

Get positions of all non zero matrix elements

I want to find all non zero elements of a table and I want to create a list that contains the name of the table the element was removed from, the position of the element, and the value of the element. ...
2
votes
2answers
172 views

How to replace data in a list (tree) in a functional Mathematica way?

I have list containing 2D points in various groupings, i.e. points, lists of points (figures), lists of lists of points (patterns) and finally a list of patterns. The list also contains other data, ...
2
votes
3answers
359 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 ...
2
votes
2answers
316 views

How to populate a table using a rule replacement

I am trying to populate the rows and columns of a table by using a rule replacment. To generate a table that looks like this For example Sc would be row 1, column 1. An example of a record looks ...
2
votes
5answers
161 views

Test First row of matrix

What is a good way to test the first row of a Matrix to check if one of the values equal a value. For instance, In this example, I want to get vector in the second row that has the bigger value in the ...
2
votes
2answers
113 views

Matching a case when one element in a pair is Null

I've got a dataset of laitutdes and longitudes. Unfortunately, some of the dataset was from when a time when lat/longs weren't constantly recorded. So I need to remove the invalid data before working ...
2
votes
3answers
122 views

How to multiply specific columns in a matrix of data?

So I need to make a plot of some ~2000 data points I have from a spreadsheet. I'm able to import the data just fine, it stores it like so sundat ...
2
votes
2answers
169 views

Create Table of replacement rules

I want to create a table of replacement rules. ...
2
votes
3answers
155 views

Wrapping a data selection in Mathematica

I was wondering what would be the most efficient way to add brackets to given elements in my data set in order to change it's form from {{a,b},{c,d}} to {{{a},b},{{c},d}}. I took a look through a few ...
2
votes
2answers
119 views

Elegant way to rearrange year/date table into time series/values

I often have data in the form of YEAR JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC 1950 -1.022 -1.146 -1.289 -1.058 -1.419 -1.36 -1.334 -1.05 -0.578 -0.395 -1.151 -1.248 1951 ...
2
votes
2answers
255 views

Covariance of a P x M x N matrix

I have a stack of tiff files. When imported to Mathematica, they form a $P \times M \times N$ matrix, where $P$ is the number of single images in the stack, $M$ is the number of horizontal pixels and ...
2
votes
3answers
284 views

Introduction of straight Line into Manipulate function

I just want to implement a line within my chart that starts from time point 0 to time point T and whose y-coordinates can be manipulated, which in my case is represented by D. I tried to implement a ...
2
votes
2answers
414 views

How can I transform a list of binary digits into integers?

I want to transform a list of binary digits into integers. With the Table function, I produce four lists of binary digits of length 32. Then I tried to turn these ...
2
votes
2answers
327 views

Pattern test for variables during function definition

I am having a problem with pattern testing on variables during function definition ...