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

learn more… | top users | synonyms (3)

5
votes
4answers
216 views

Dynamic list in which the sum of the elements is invariant under changes to the elements

2nd Update Here's a snapshot of a graphical user interface I'm thinking. I hope this could be self-explanatory and demonstrate the functionalities I mentioned in the 1st update. Thank you all! ...
0
votes
0answers
39 views

What is the right way to remove head of a number? [duplicate]

I often have a number for which I want to remove its head, e.g. {1}. I know of two ways to remove the head: {1}[[1]] # & @@ {1} Neither of these methods seem ...
3
votes
2answers
117 views

Plot 2d-ItoProcess data in a plane

I am trying to simulate a simple 2d Ito SDE (randomly perturbed Hamiltonian system). Below is the code. ...
3
votes
2answers
62 views

Select elements from list with given head

I would like to select elements from list by specifying their head. E.g. SelectWithHead[{1,2,3.5,x}, Symbol] = {x} SelectWithHead[{1,2,3.5,x}, Real] = {3.5} What ...
0
votes
1answer
44 views

How to loop in a nested Association?

Considering we have an Association: ...
0
votes
2answers
29 views

Multiplying columns of a list of matrices

I have the following list of matrices ...
19
votes
2answers
230 views
0
votes
0answers
44 views

BinLists for list of depth greater than 1

BinLists uses the bin specification assuming an interval that is closed on the left and open on the right (according to the documentation). So ...
3
votes
1answer
56 views

How to combine keys in nested list of rules or associations?

Considering we have a list of rules: ...
-1
votes
1answer
58 views

Beginner Question: Assigning an indexed Variable to a given list

I am pretty new to the game and have a problem, which i am sitting on for hours. 1) I created a random Matrix 5x5 ...
2
votes
0answers
73 views

How do I flip x and y value of a list in mathematica? [closed]

I am very new to mathematica. I have been trying to the following without any success. I have a list like this : data = {{1,2},{3,4},{5,6}}. I want a list ...
1
vote
1answer
70 views

Import csv file which contains columns of different lengths --> How can I delete empty fields?

I have the following problem: I want to import a csv file into Mathematica. I file as a lot of rows and columns, but the column lengths differ for certain rows. 2 columns always belong together, ...
0
votes
1answer
81 views

Trapezoid approximation to definite integral

this question is related to Basic question on defining more rectangles. I now was trying to adapt the code by MarcoB to get the approxiamtion of the integral by trapezoids, and I used the function ...
0
votes
0answers
33 views

Exporting the NDSolve to matlab with the argument

a = Table[Evaluate[y[x] /. sol], {x, 0, 10, 0.01}]; Export["a.mat", a]; works just fine but ...
1
vote
2answers
88 views

Slicing multidimensional table

Say I have a multidimensional list created in the following way grid= Table[{i, j+1, k+2}, {i, 0, 1}, {j, 0, 1}, {k, 0, 1}] grid={{{{0, 1, 2}, {0, 1, 3}}, {{0, 2, 2}, {0, 2, 3}}}, {{{1, ...
10
votes
4answers
370 views

Graphically approximating the area under a curve as a sum of rectangular regions

I am completely new to Mathematica. Basically I was trying to write a code to plot a function and draw the approximate area by rectangles. To be more precise, plot a function ...
2
votes
5answers
115 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
184 views

Counting variable from a list of matrices

I have a list of matrices ...
0
votes
1answer
80 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
158 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
76 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 ...
1
vote
1answer
77 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 : ...
4
votes
2answers
122 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
118 views

Generate a list with random values between a and b [closed]

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 ...
3
votes
2answers
60 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 ...
14
votes
1answer
797 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
88 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 ...
0
votes
2answers
103 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 ...
1
vote
5answers
155 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
54 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|> ...
0
votes
1answer
58 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
1answer
62 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 ...
0
votes
0answers
57 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: ...
3
votes
3answers
118 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
39 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 ...
2
votes
4answers
100 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, ...
7
votes
7answers
423 views

Generate a list

Given the list o = {xmin, xmax, ymin, ymax}; how can I generate the following list? ...
0
votes
1answer
84 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 ...
0
votes
4answers
103 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 ...
0
votes
1answer
63 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 ...
1
vote
1answer
32 views

Truncating a List of Subsets of Ordered Pairs

I have a set of pairs: ...
1
vote
5answers
141 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
0answers
67 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
1answer
52 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
119 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 ...
1
vote
1answer
37 views

Replace parts of nested lists

I have list of stock data as follows: lis1= {{{1992/10/12, 126.946, ^AEX}, {1992/10/13, 127.85,^AEX}}, {{1992/10/12, 88.487, ^AFLI},{1992/10/13, 91.825,^AFLI}}} ...
0
votes
0answers
55 views

How to replace a part of array based on certain rules which involves usage of other array

I am trying to replace outermost column of array "fd" in below code. fd is matrix of dimension (nas1,nts) which is initially filled with 1. I want to replace outermost column of fd with result of Max ...
6
votes
3answers
234 views

List and patterns

Given some tuple $\{N,M,L\}$ such that $N\geq M\geq L\geq 0$ and $N>0$, how can I generate all tuples $\{n,m,l\}$ such that $n\geq m\geq l\geq 0$ and such that ...
1
vote
2answers
42 views
1
vote
3answers
98 views

2D Interpolation of data file

I hae a datafile with 5 columns of the structure: x_i f(x_i,y_1) f(x_i,y_2) f(x_i,y_3) f(x_i,y_3) f(x_i,y_4) with i = 1 to about 100. Thus there are about ...