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

learn more… | top users | synonyms (3)

2
votes
5answers
100 views

Cut nested lists based in another nested list

I have a list of data with nested lists of different length in the following format: dataLis={{1,2,3,4,5,6,7,5,4},{2,3,1,5},{4,5,6,7,7,8,9}} Now I have ...
5
votes
4answers
155 views
7
votes
5answers
420 views

Calculating weird numbers

A weird number is a number such that the sum of the proper divisors (divisors including 1 but not itself) of the number is greater than the number, but no subset of these divisors sums to to ...
0
votes
1answer
66 views

How do I manage my memory better when using the Map function?

So I'm attempting to write a Mathematica program that prints a range of natural numbers as the sum of four cubes. I wrote the following Mathematica code to try this, but am running into a memory ...
5
votes
3answers
139 views

Select certain items from nested list

I have a list as follows: lis1={{{a1,b1,c1,d1,e1},{a2,b2,c2,d2,e2}}, {{a3,b3,c3,d3,e3},{a4,b4,c4,d4,e4}}} and would like to delete certain elements from it resp. ...
3
votes
2answers
64 views

Manipulation of .csv imported data — no blanks in either of two lists

Above is a .csv file. I am trying to construct two lists of male and female math test scores such that only districts which include info for both male and female students are included i.e. neither ...
5
votes
3answers
254 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: ...
1
vote
1answer
87 views

Modifying a list of matrices with conditional statement

I have a list of around 100 matrices, that looks like this ...
1
vote
1answer
67 views

Take sublist with fixed interval

For example: a = Range[20]; a = ArrayReshape[a, {4, 5}] I want to take elements from a with interval = 2 : ...
24
votes
6answers
9k views

How to find the position of elements in a list satisfying criteria

Say I have a list x={2,4,6,8,10} and I want to find out the positions of the elements that are greater than 7. ...
4
votes
2answers
106 views

Gridding in a Nested Matrix

We have a nested matrix as: nested={{he, {{e, f, g, h}, {s, 0, q, i}, {s, 0, q, j}}}, {ho, {{e, f, g, h}, {0, u, t, i}, {u, t, 0, j}}}} and with the line ...
0
votes
2answers
91 views

Generate a list with random values between a and b [on hold]

I am trying to perform system identification.. To properly identify the system i have to give the system a "rich" signal which are able to "activate" all the modes of the plant. A rich signal would ...
0
votes
2answers
88 views

Specific excel data needed in a list

I need to create a list from a general Excel database that requires only data from "ALL STUDENTS" rows on columns 2 and 7. The List most be of the form {DISTRICT, MATH} where the MATH score is ...
3
votes
2answers
54 views

Average list of list of parameter values

I have a list of lists of fitted parameter values, e.g. list={{a->1,b->10},{a->2,b->20},{a->3,b->30}} (the actual parameter names can vary, as ...
11
votes
1answer
611 views

Solving and Animating Three Body Problem

I am attempting to solve a three-body problem using the Lagrange formalism, with a 1/r potential. I started off by defining T and U (kinetic and potential energy) as follows: ...
1
vote
3answers
73 views

Getting a list of x coordinates of intersection points of two functions

I have two functions, f[x_] := 5 Sin[2 x] g[x_] := (5 x + 2)/(x + 2) I am trying to find the x coordinates that intersect ...
6
votes
6answers
488 views

Convert a list of rules into 2 lists of integers

If I have a list of n number of rules, what is a concise way of breaking the data into 2 lists of the first and second part of the rule? This works, but seems like an unnecessary amount of code to ...
4
votes
4answers
670 views

Writing a circular matrix

I have two square matrices, $A$ and $B$, of the same size, say, of $m \times m$. What I want is to write a programme/function of three variables, $A$, $B$ and $n$, that outputs the $mn \times mn$ ...
0
votes
1answer
38 views

How to extract info from Association? [duplicate]

How can one extract a list of keys and a list of values from the association? e.g. as = <|a->1, b->2, c->3, d->4|> ...
1
vote
5answers
142 views

Select a certain row among the duplicates

I have the following problem: I have a (a lot)*3 table, meaning that I have 3 columns, say X, Y and Z, with real values. In this table some of the rows have the same (X,Y) values, but with different ...
0
votes
1answer
49 views

Joining sub-lists nested two levels deep in a list [closed]

I have an obviously easy task, but I can't do it, and I could not find a solution by searching the site. I have a list as follows: ...
1
vote
5answers
137 views

Manipulating List?

I have a huge list with 1000 elements. Manually entering and calculating SUM of probabilities it would take a few hours. Example: list = {1, 2, 3, 3, 4, 3} ...
0
votes
1answer
56 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 ...
7
votes
7answers
370 views

Generate a list

Given the list o = {xmin, xmax, ymin, ymax}; how can I generate the following list? ...
0
votes
0answers
30 views

Command Select returns empty result [closed]

I'm trying to do something like c = N[Solve[14 == 3x^2+4x+1, x, Reals]] Select[c, 1 < # < 2 &] Unfortunatelly, I get ...
1
vote
1answer
54 views

Incompatibility of Append and NumberForm? [closed]

Consider the code list = {.12, .23, .34}; Append[Round[list, .1], 10] Append[NumberForm[list, 1], 10] The use of Round returns the expected result ...
3
votes
4answers
219 views

Delete Missing data from coordinate sets

I have a list of pairs of coordinates, where some are missing. ...
1
vote
6answers
205 views

Deleting missing data with CountryData

I need to delete all of the missing entries after executing this line: ...
1
vote
3answers
182 views

How to manage list of list of rules?

Considering we have a list: str = "{1 -> {a -> aa, b -> bb}, 2 -> {2a -> \"{b -> bb}\"}}" Bringing this to expression gives: ...
0
votes
0answers
54 views

How to handle substrings of a matrix by a named index

I am using open source code to run stochastic simulations. The output looks like this: ...
2
votes
3answers
105 views

Max function used with nested lists

I have a list as follows lis1={{{1,5,6},{4,7,8}},{{1,2,2},{5,6,7}}} and would like to calculate the max value of each nested list in order to get following ...
1
vote
0answers
28 views

Tracking solutions over a Brillouin zone

Thanks to @bbgodfrey I have a function that finds the two solutions to a set of equations bounded by a hexagonal region (corresponding to the Brillouin zone). It takes the angle ...
18
votes
4answers
398 views

Make MapIndexed listable

My goal is to apply MapIndexed to every element of a nested list without destroying the arithmetic operations within the elements. For example, let's start with ...
2
votes
4answers
84 views

Pairs of data to Classify[]

Suppose I had the following data a={1,2,3,4,5} How would I turn this into b={{1,2,3}->4,{2,3,4}->5} That is, ...
4
votes
2answers
97 views

Output function control and manipulation for efficient computation [closed]

I have taken note of a similar post related to modifying function parameters. I tried to adapt Kuba's solution to this post but I can't get it to work. I will illustrate my problem using a similar ...
0
votes
1answer
51 views

How can I use nonlinear model fit with multiple variables? [closed]

I have a data set with four entries. the first three entries correspond to variables in the fit x,y, & z. The fourth entry corresponds to the function value. I am trying to fit this data to a rate ...
8
votes
1answer
111 views

ListConvolve Memory Hemorrhage

I wrote a routine that convolves an impulse response array with a test array and checks for the RMS difference between that convolution and a data array. I do this iteratively so that I can modify the ...
3
votes
0answers
126 views

FindPeaks finds Minima, but not all of them [closed]

I have 10 sets of data, which are the result of measuring the way of a mass falling down over time, bringing a wheel into rotation when the mass hits the ground and then the wheel lifts the mass up ...
24
votes
4answers
4k views

K-means clustering

In MATLAB, there is a command kmeans() that divides an array into $k$ clusters and calculates the centroid of each cluster. Is there any command in Mathematica to ...
0
votes
0answers
64 views

Matrix iteration failing after second step

I am calculating 11x6 matrix using different logics as in below code. Problem is in Do loop in below code where I have two different criteria to update matrix "fd". I am expecting logic in IF which ...
0
votes
4answers
87 views

How to trim the zeros from the right of a list? [duplicate]

I need to remove the zeros from the right of an integer list up to the first non-zero element. Such as {0,1,0,0,2,0,0}->{0,1,0,0,2}. Padding zeros can be simply ...
5
votes
6answers
579 views

Can Mathematica delete some of the 0's from a list?

I have a list: {1,2,3,0,0,4,5,0,0,0}. I want to delete the 0's occurring after the last positive integer. In other words, I ...
0
votes
1answer
46 views

How to import data from a .mat or a .txt file and manipulate dimensions

I'm new to Mathematica (I know very, very little - so I apologize if anything I say is absolutely wrong) - but I'm trying to upload a file from matlab and arrange it in matrix form. I have a .mat ...
30
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 ...
18
votes
5answers
1k views

Moving maximum function?

How can I construct a moving maximum function? For example, if I have a list of 12 values: { 5, 6, 9, 3, 2, 6, 7, 8, 1, 1, 4, 7 } and I want to maximize over 3 ...
1
vote
1answer
30 views
0
votes
1answer
45 views

Replace element of matrix based on rule which invloves other element of same matrix

I am trying to replace 1s row of matrix d iteratively from right by multiplying last element in 1st row with (1-int*dt) to generate 2nd last element. The replacement continues till I reach the 1st ...
1
vote
2answers
117 views

How can I reshape my solutions to make a 3D plot?

I need some help on the following. I need to run Solve for multiple values of a and b. To do so instead of using Do, I use ...
2
votes
2answers
109 views

Dynamic arrays and lists with compile (Append, Linked lists etc.)

I have a code that I need to compile. The code contains a loop in which I need to gather data into a list. The question is how to best gather data so that the code works inside Compile. The following ...
3
votes
1answer
187 views

How can i subtract a surface from another

I have one surface which i got with using analytical solution. And one by ListPlot3D. My question is how can be withdrawn from the one from the another. ...