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

learn more… | top users | synonyms (5)

0
votes
2answers
50 views

How do I add the nth element for every line in a text file?

Suppose I have a text file, in this format: ...
0
votes
2answers
77 views

Fitting a Gaussian model to specific section of my list?

I'm analysing some Decay sepctrums for a Nuclear Physics project. I need to fit a gaussian model to a specific X-Ray peak to determine the centroid so I can get a good channel-energy calibration. ...
0
votes
5answers
156 views

How to expand a MxM matrix with replicates of itself and drop some of the rows and cols periodically?

How can I expand a 2d-matrix with dimensions x,x (e.g. mat = {{ 1, 2 }, { 3, 4 }}) with replicates of mat into ...
0
votes
1answer
24 views

Question about loading data by skipping

. It is often important to take data and measurements and give them a name which has a number, and manipulate them in a for loop fashion to manipulate a large data base efficently. The loop above ...
3
votes
1answer
49 views

Returning maxima of multiple sets

I am trying to prove a conjecture which involves the SetParitions[n] function (which requires the Combinatorica package). This function returns a list of all the set partitions of n. I'd like to take ...
4
votes
2answers
166 views
3
votes
0answers
69 views

Mysterious Riffle::rspec warning

I have part of a code that looks like this: ...
1
vote
2answers
107 views

Filtering and summing sublists with Cases

I've declared a list: list = {{1, 2}, {2}, {3, 4, 1}, {5, 4}, {3, 3}, {a, b, c}, {e, f}, {g}, {}, {Sin[a], Cos[b]}}; now I've made an rule which add 2 pairs ...
2
votes
0answers
36 views

How to delete lines containing specific values from a matrix? [closed]

I am doing some numerical computations and a few iterations return values that are obviously incorrect (some numerical integration problem, I suppose.). I have managed to set these values to zero but ...
2
votes
0answers
25 views

Matching list entries by two values, adding the third [duplicate]

I have data in form of: data={{1,1,3},{1,1,6},{2,1,7},{2,2,4},{2,1,1}}; I want to match the entries with the same first two elements and add the third element in ...
1
vote
0answers
42 views

Select and use only one solution in a list solutions [closed]

I would like to use and plot only one of the two solutions of a quadratic equation. In particular this is my equation ...
1
vote
1answer
61 views

How to output the entries of two lists as equal without evaluation? [closed]

Question So, for example, I have the code here: ...
2
votes
1answer
99 views

Alternative for AppendTo [duplicate]

as I'm well aware, using AppendTo for large lists isn't recommended as the function gets progressively slower with each appending done. Lots of suggestions talk ...
1
vote
1answer
87 views

Automatically generate and manipulate variables in Mathematica

First line is just loading data from a txt.file, so that i get two lists {f1,f2,f3,..},{laser1,laser2,laser3,..}. How can I do the same thing as above in just one line? i.e. I have a list of laser ...
1
vote
0answers
40 views

Applying slots, one after another for a list [closed]

For this function: Fun[x_] := 3 x^3 + 4 x^2 - 2 x - 1 I apply Map: D[Fun[x], {x, #}] & /@ Range@3 and I get this ...
1
vote
0answers
82 views

DeleteDuplicates [closed]

After having applied "DeleteDuplicates" to a list of data (15000 rows per 3 columns), when I try to interpolate that list of data it gives me back again: "There are duplicated abscissa points in.." ...
0
votes
1answer
50 views

How To extract data to plot it from a log file

i want to extract out the data (number) from 'geometry step' and 'total energy' in form of list to PlotList[] it. this is the Log file data log Abstract the Total ...
3
votes
5answers
141 views

ListPlot with colors

Let's create some sample data n = 100; d00 = Table[{RandomReal[{-1, 1}], RandomReal[{-4, 4}], RandomReal[{-1, 1}]}, {i, 1, n}]; Now I want the following: create ...
0
votes
1answer
38 views

Export list entries under a certain condition without using loops

I have a big list that contains many 3D- chains (set of points) and for each of them a polynomial. So the structure of my list is for example ...
1
vote
0answers
62 views

Distinguish hashtag # operator when using multiple functions [duplicate]

I would like to do this list = Append[list[[#]],Map[list2[[1, #]] & , list[[#, 4]], {2}]] & /@ Range[Length[list]]; But I would like to substitute ...
1
vote
2answers
43 views

TexForm List with Rule

I'm having some difficulty TexForming a list. The output is not what I want. The following is a minimum working example. I've tried every combination of Flatten, ArrayReshape, and Partition to no ...
1
vote
2answers
73 views

Export many lists without using loops

I have a Mathematica function that creates a RandomWalk chain of length l, by generating random points on the unit sphere and ...
1
vote
1answer
41 views

Setting the value of a list item

I want to set the value of an item in a list. The code that does this has to work regardless of the depth to the list. For instance set the value of r[[1,1,1,....,1,1]] to 9. Lets say the list called ...
0
votes
2answers
64 views

Automatic process to replace missing values, coming from a second matrix

I have a large starting matrix with missing values in different columns. I want to replace this missing data as follow. First I have to check the group (last column in starting matrix) and go to a ...
1
vote
2answers
57 views

Discard Elements of list with given criteria

I have the following list: ...
1
vote
2answers
86 views

Count pairs from a List

I have a list of numbers: ...
3
votes
1answer
70 views

Pareto optimal fronts using internal function?

Reading this question: How do I estimate the Pareto front in my multiobjective optimization problem? I found @Daniel Lichtbau's interesting answer. Yet I don't know how such an "internal function" ...
3
votes
4answers
171 views

Is there a way to PrependTo or AppendTo while flattening the result in the same step?

arr = {1, 2, 3}; PrependTo[arr, {a, b}] (* {{a, b}, 1, 2, 3} *) But, I want (* {a, b, 1, 2, 3} *) I know I can use ...
4
votes
3answers
132 views

how to apply Alternatives command to delete cases from a list?

I have two lists let say listF = {{7, 2}, {2, 6}, {8, 1}, {1, 7}, {11, 8}, {6, 11}}; and ...
3
votes
1answer
70 views

Duplicate rows with multiple entries

I have a huge dataset, which looks similar to this: ...
1
vote
2answers
99 views

Find the minimum element of a row of a matrix and its column index for each row

I am trying to find the minimum value of a row of a matrix and its corresponding column. Please run the code below. OptV is the matrix that I would like to create which must give the output of the ...
15
votes
3answers
340 views

Find duplicates in list of InfiniteLine

MMA 10 introduced a new function, which can be very convenient: InfiniteLine. Of course, two infinite lines can be described by different arguments: for example ...
0
votes
4answers
62 views

Matching a Table and a List and building a new Table

I have a Table which includes {Numbers, Probabilities}. For example A= {{1,0.5},{2,0.25}, {3,0.1},{4,0.9}……{100,0.1}}. Put attention that the numbers are 1,2….100 in order. I have a List of random ...
4
votes
2answers
239 views

How do I encode this replacement rule?

I'm pulling a 5x5 array from a larger array. The small sub-array (call it S) can contain any combination of the symbols A, B or 0. What I'd like to do is: if the array contains any matching pairs ...
3
votes
1answer
76 views

What's the easiest way to find the closest point in a list of pairs?

I frequently end up in this situation. I have a solution, but I suspect it's the dumbest way of doing it. Frequently, I'll have a list of pairs, for example: ...
1
vote
1answer
46 views

NRoots Results: From Equations to List of Root Values [closed]

When I use Roots/NRoots, I get a disjunction of conditions as result. The conditions are normally of the type x == value How can I convert this to the list of root values?
2
votes
2answers
68 views

Creating a custom ListPlot of consecutive points

Here comes some sample data ...
6
votes
3answers
292 views

How do I split a list of numbers to monotonic sequences?

Suppose I have: list = {1, 2, 4, 5, 7, 11, 8, 7, 3, 1, -3, -2, 6, 7, 80} And I want to split it to: ...
3
votes
1answer
74 views

Untangling a tangly block of If statements

This is a followup to my previous question: How to simplify block of multiple repetitive If statements? I have another block of If statements, somewhat like the other one I need help simplifying ...
3
votes
3answers
97 views

Extract every nth character from a string

I'm trying to extract every 21st character from this text, s (given below), to create new strings of all 1st characters, 2nd characters, etc. I have already separated the long string into substrings ...
3
votes
3answers
178 views

Drop in nested tables?

I want to drop a specified number of elements from a 'table ...
5
votes
4answers
449 views

How to simplify block of multiple repetitive If statements?

I'm building a boardgame...game in Mathematica. I have the board state represented as a matrix. It's a two player game, and each player (let's call them A & B) only has one type of piece or ...
3
votes
4answers
135 views

Find the length of the intersection of two lists including duplicates

I have 2 Lists. The first one includes all the numbers from 1 to 10. listA={1,2,3,4,5,6,7,8,9,10} The second includes ...
0
votes
0answers
39 views

Pass List / Vector argument through NDSolve to a function

I am trying to pass vector or list as argument to the function from NDsolve.And I am getting these error. Also I am pretty new to stack overflow. Apology if this a possible duplicate. Here is my code. ...
10
votes
6answers
577 views
3
votes
0answers
78 views

Kernel crashes when computing finite difference mixed derivative with respect to y & z but works fine when computing with respect to x & y or x & z?

I am using Mathematica 10.4.0 on Ubuntu 16.04. I am trying to solve a set of differential equations using finite difference method on an NxNxN cubic grid (x, y, z directions). I am getting a weird ...
1
vote
1answer
79 views

Use Map on a Function with two variables

I am new to Mathematica and I would like to find out how to use Map on a function with two parameters such as: ...
4
votes
3answers
268 views

Enforce monotonicity in a list

Suppose I have a list containing pairs of complex numbers. For example: ...
0
votes
0answers
61 views
1
vote
3answers
334 views

Matching the order of a master list of lists from a random list of lists

Using Mathematica 9, I have 2 lists of lists one master with dimensions {300, 6}. The second is some random order but has the same first ...