# Tagged Questions

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

151 views

### Having problems with ListPlot and a PaddedForm wrapper

I defined a function f[x_] = x^3 2 x. Then I had to construct a table showing vertically, the values of f corresponding to x on ...
586 views

### Faster “stuttering” accumulate?

Given some list of arbitrary precision numbers, e.g. (actual lists are 1M+ elements long): test={0, 2, 2, 47839283, 2, 0, 0, 2, 0, 1, 2, 0} I need to accumulate ...
382 views

### Generating complete lists of polynomials

I would like to generate a list of all $3$-variable Laurent polynomials with non-negative integer coefficients using a looping construct so that I can, one-by-one, check them for specific ...
701 views

### List density plot for non-uniform data

I am trying to make a density plot to show the data that can found here. I tried with GNUplot previously. The result of GNUplot density plot for a rectangular set of data. I am able to do this only ...
239 views

### What is wrong with setting one list to another within function? [duplicate]

I have built a function which carries out a set of operations given two parameters. The function looks as follows: ...
2k views

### How to find non zero elements of a list containing zeros and symbols

I have a list, obtained after differentiating a list of expressions, which contains zeros and symbols, say: A = {x1^2, x2^2, x3^2, x4^2} D[A,x3] results in the ...
96 views

...
29 views

### How to put the values/points in a loop into a plot? [duplicate]

I've already make the do loop..it has 200 points..how am i going to put those points into a plot?do i need to make a list@table before doing the plot?here's my loop example, ...
322 views

### Create Table of replacement rules

I want to create a table of replacement rules. ...
57 views

### Replacing list elements by other list elements [duplicate]

I am a beginner of Mathematica and need some help for the following issue. I have the following two lists: ...
357 views

### Taking Top K Occurrences

Having millions of numbers in a list, I want to take top K occurrences. MMA Commonest is very slow so I write my own versions: <...
265 views

### Split list of states by run lengths and discontinuous changes in state

I was asked to look into writing some simulation code for a user, where the simulation output (x) would oscillate between three possible states: ...
885 views

151 views

### How to save the results in an identical Excel file (.xls) in each iteration of a Do loop

Assume the following code (Below code is just an example to clearly illustrate my problem): ...
186 views

### How to make list plot when all information is in a single list

I want to make a plot , where the data is structured like so { {"l1", "l2"}, n1, n2, n3} } The values in the inner sub list are labels which are associated with ...
40 views

### Filter sublists that contain a certain value [duplicate]

This question is a followup from appending elements to sublist mergedList = { { {"a","b"}, -1.5, -5, "no" }, { {"c","d"}, -2,-10, 7 } } I ...
89 views

### If statements with a Boolean [duplicate]

If I have a vector {1,2,3}, I want to write an If statement, where if one of the positions is "1", it will perform a certain command. ...
482 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 ...
194 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 ...
264 views

### Comparing Positions of Elements in a List

How can I check if Position[i] > Position[j] for two arbitrary elements in a given list? The problem is that Position[i] ...
308 views

### Conditional search along the columns of a matrix

I want to implement the following algorithm in Mathematica. Get element along main diagonal of a matrix. If the element along the main diagonal is positive, then return the positions of the elements ...
612 views

### Breaking a sorted list into bins of a specified size

Can somebody please explain me the following: If I try to split data every increase in 0.5: ...
331 views

### Change input variable in a function [duplicate]

I'd like to write a function, that would take a matrix as an input parameter and would change it by multiplying one of its rows by a factor. I try to do it in the following way: ...
456 views

### Plotting with ColorFunction -> GrayLevel - no black

This is probably a fairly trivial question, yet I have been unable to find an answer - help would be much appreciated! :) I am trying to plot a 28 x 28 matrix (tabulated data given here), containing ...
287 views

### adding a 1 to all second elements

I want to add 1 to all second elements but I am running into a "level" problem I believe here is my code: ...
623 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 ...
148 views

### Subtracting list from list of same dimensions [duplicate]

This might seem like a basic operation I have already searched for similar answers but found none. I want to subtract the second elements of my list ct from the corresponding element in lt, and ...
219 views

### On elegant use of Inner and Outer on tensors

I have a collection of 5-element vectors each of which corresponds to an {x,y} location from a (20 x 21) grid. Because of that I represent that data as a (5 x 20 x 21)-sized tensor called ...
1k 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. ...
334 views

### Accumulate second elements in sublist

I want to accumulate the second elements in each sublist identified by its first element. ...
157 views

### Path construction using Nearest shows ill behavior?

I have a dataSet that I'm trying to sort choosing a starting point and going to its nearest neighbor, and then to its nearest neighbor and so on. To do so, I've ...
99 views

### List operation on specific elements [duplicate]

Let's consider two tables given by T1 = Table[{i,j,f1[i,j]},{i,0,2},{j,0,3}]; T2 = Table[{i,j,f2[i,j]},{i,0,2},{j,0,3}]; The functions ...
2k views

### What is the efficient way to code Successive Over-relaxation (SOR) method in Mathematica?

I have written a SOR method (SOR is this method) code using C-style procedural loops. However, I think there might be (much) better ways to achieve the same end in Mma avoiding these loops. So my ...
660 views

### Apply color function to matrix plot

I want to apply the following color rules to a large table of numbers. I have extracted a part of the table to use as an example. I would like to assign 5 different colors to 5 different ranges of ...
402 views

### Simple subtraction question [duplicate]

I have two lists. a = {{2, 2}, {3, 3}, {4, 4}, {5, 5}}; b = {1, 1}; I want to subtract a from ...
148 views

### Ordered indices of a multiple product or sum

Given a summation like $$\sum_{1 \leq i_1 < i_2 < \dotsc < i_k \leq n} f(i_1, i_2, \dotsc , i_k)$$ how can the lists of indices be enumerated? For example, if $n=4$ then the possible lists ...
581 views

### Riffle and Partition

At some point I noticed that I was using Riffle and Partition together a lot. I would do things like ...
221 views

### How can I create a list containing the normalized element-by-element product of two given lists?

I have to calculate: How can I create such a sum? Do I have to set the factors of each term manually (one by one), like G1 = 1, H1 = 1, G2 2, H2 = ....? ...
112 views

### How to generate a list with a loop, and put it into a variable?

I am pretty new to Mathematica and to coding in general. I want to do a very specific thing, but I unable to do it. Please explain in detail how I can make this work. Here's the details on what I am ...
500 views

### Select cases from a list

I have a list in the form : {1,1,1,0,-1,-1,1,1,1,0,0,0,0,-1,-1} No I'm trying to select only those sequences which start with 1 have a zero (or many zeros) ...
217 views

### How to select the first “lowest” (first valley) number in a list?

I would to select the first valley of the list of coordinates below. It should be {3, 1}. ...
110 views

### Matrix Operation

I have a $3\times3$ matrix A, and a function sTrans that outputs two $3\times3$ matrices in a list when given a $3\times3$ ...
242 views

### Strategies to find curves on messy data using FindCurvePath

I have a set of data points that correspond to roots of a transcendental equation with respect to a parameter (the abscissa) which, by the properties of the system, define continuous curves (might be ...
130 views

### How to test if any set of pairs contains elements of other list? no matter order of elements

I want to detect if a set of pairs, for example a={{2,5},{6,3},{1,4},{8,7}} contains a given pair, for example tabu={{4,1},{2,6}} but don´t be relevant the order inside pair (pair {i,j} is equal to {j,...
27 views

### How to switch elements i,j in a list? [duplicate]

Are there any direct function to switch elements i,j in any list? or is necessary to create one with Do / If ? (I don´t ask for making me this function if it doesn´t exists) My target is can ...
21 views

### How do I plus these values in a list [duplicate]

Hi I need to plus 3 values together each time for the rest of the list. How do I basically add the 3 sets of values together each time. When I try Plus[] it returns the same input values back to me ...
126 views

### How do I use Subgraph to sample the $n$ vertices of a graph with the greatest connectivity?

Let $G$ be an arbitrary graph with some number of vertices $||V||$ and some number of edges $||E||$. We can use Subgraph to generate, well, a subgraph of ...
652 views

### Undocumented form for Extract

Prompted by a comments conversation here, here's an interesting (and often performance enhancing) use of Extract: ...