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

learn more… | top users | synonyms (3)

3
votes
1answer
78 views

Use Style on list elements

I have a list like this: list = {0, 0, 0, 1, 1, 1} I want to color all the 0's in red, but I dont want to count through all the elements, like in my solutions, ...
4
votes
2answers
110 views

Is there a built-in function to map a list of heads to a list of data?

Assume that this built-in function is called func. What I want is func[{f,g},{a,b,c}] will return the following result: ...
3
votes
1answer
51 views

Part specification error only in LogPlot

I've a problem. I defined a simple list and a function like below: lst := {5, 10, 20} f[m_] := lst[[Floor[m/10]]]; and drew a plot ...
5
votes
2answers
104 views

Return value of Reap when using tags

I've noticed a behaviour of Reap that I don't quite understand yet. Suppose I want to Sow several values during a computation. ...
16
votes
4answers
333 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 ...
1
vote
2answers
634 views

Computing 10-dimensional volume of a 9-sphere [closed]

I'm trying to compute 10-dimensional volume of a 9-sphere with radius r using Monte Carlo. ...
1
vote
1answer
141 views
2
votes
2answers
146 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 : ...
6
votes
2answers
216 views

Converting a string into a nested list of strings

The following string can be converted easily into a list with ToExpression ...
3
votes
2answers
100 views

How to modify the elements of a list in a loop?

I have a list with points coordinates. And I'm trying to traverse it and perform some matrix operations on each point. But I have a problem with storing modified points in the initial list instead of ...
2
votes
1answer
84 views

How to build a list of constraints for NMinimize

Let's say I have aset = {-1, 0, 2}. I would like to create a variable Var that takes values from that set, i.e. ...
7
votes
5answers
307 views

How to display operations on list elements

When applying some arithmetic operation on two lists, I'd like to display the actual operations between the elements of each list. For example, {1, 1} + {1, -1} ...
1
vote
3answers
128 views

How to ReplaceAll independent of depth?

I have a big list which in principle can be described as this more compact list : ...
0
votes
1answer
135 views

How to plot data points in the form X, Y, E(X, Y) where X and Y coordinates are not ordered?

I have got a file with field values (RF simulation of a resonator) which consists of 3 columns: X and Y cartesian coordinates ...
1
vote
1answer
64 views

Remove curly brackets _completely_ to map a function to the elements of a list [duplicate]

Most list manipulations can be done with Flatten, Partition and Take. I didn't managed to ...
2
votes
4answers
131 views

Import xls data with dates

I have an excel table that have 2 columns, the first one are dates, and the second one are values. I want to plot the value vs the date. I need to: first clean all the non numbers strings like ...
5
votes
1answer
245 views

How to split a Dataset into training and testing for machine learning?

Suppose I have iris data In the Dataset Format. How to split the iris data Into training and testing for Machine learning? For example,Transform the data for Classify.
6
votes
3answers
266 views

Rotate lines around their midpoint

I am trying to rotate a series of lines by the same angle around their centre point. Say each line is defined by a co-ordinate at each end, simplified example below of a typical dataset. ...
1
vote
1answer
75 views

How can I write a function which takes another function of a variable and the variable itself as arguments and gives a list of critical points?

This is an exercise from Power Programming with Mathematica by Wagner. I need a function which takes a function and a variable as arguments, like this: critpts[f_,x_]:= and then on the rhs I've got ...
3
votes
1answer
105 views

Read and write files

I have a text file, its content is(for example): ...
3
votes
4answers
186 views

Replace all symbols in a matrix with their numbered forms

I have a matrix made mostly from "x" with a few 0's thrown in: ...
6
votes
2answers
163 views

Problem when defining function through NIntegrate and NDSolve and Interpolation - Bug?

More than a single question, I have some doubts about the output of certain functions when defined through the result of other calculations. I am an active user of Mathematica, but maybe I haven't ...
4
votes
3answers
158 views

unlisting a nested list

I have a list like this: list = {{a,{1,2,3}},{b,{1,2,4}},{c,{{1,4,5,5},{6,3,2,1}}}} This is a nested list which each element has a name. I want to export it to ...
1
vote
3answers
115 views

Removing some data and replacing them with new ones

I have a data list where the elements have the form (time, velocity ). I need to remove some malformed elements in places where the data does not change smoothly and then replace those points by ...
1
vote
2answers
165 views

Replace a value in a nested array

When I run the following, ...
2
votes
3answers
69 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: ...
3
votes
5answers
197 views

First pair out of order

I would like to know how to efficiently determine the first pair of elements in a list that are not in order according to some predicate p. That is, list[i] > list[j] according to p, and i is the ...
4
votes
8answers
384 views

How to sort my list?

For example I have two lists of such structure L1 = {{"Australia",a1}, {"USA",a2}, {"Norway",a3},...} L2 = {{"Russia",b1}, {"Norway",b2}, {"Japan",b3},...} I ...
3
votes
7answers
203 views

List creation/manipulation

I'd like to a create a list from A = {{a}, {b}, {c}} by taking each elements n times in the following form: ...
1
vote
4answers
111 views

Check if a scalar falls within the range given by sub-arrays of a matrix

I have a rank 3 matrix: r = {{{1, 10}, {19, 71}, {111, 159}}, {{1, 5}, {25, 63}, {118, 132}, {164, 185}}, {{1, 19}, {28, 49}, {157, 203}}}; and each of the ...
0
votes
0answers
48 views

Generate all strings of fixed length from an alphabet [duplicate]

I am trying to create all possible strings of length $8$ from the alphabet $\{+1,-1\}$. I am trying to get help from this question. But not sure where to start from. Any help?
6
votes
6answers
409 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 ...
7
votes
0answers
113 views

How to merge Datasets representing matrices with named rows/columns?

I am working with square (non-symmetric) matrices with named rows and columns. The data I receive is sometimes messy and rows/columns may come in various permutations. I usually need to ...
3
votes
3answers
232 views

How can I change a list to a sequence without destroying nested list

I defined a function f like f[x___, y_] := something; and if xs and ...
0
votes
1answer
59 views

Map Elements of a list to be Index of matrix

I have a sublist from Tuples[{1, 2, 3}, 2], say for example L={{1,2},{2,1},{2,2}}, and a 3 x 3 matrix ...
6
votes
8answers
254 views

Merging lists and adding common elements [duplicate]

I have two 2D arrays where some of the x-values are identical, L={{1,1},{2,2},{3,3}}; J={{0,1},{2,2},{4,4}}; I want to add these lists in the following way ...
1
vote
4answers
99 views

Converting format of list

I have a 2D array, data = {{0,1}, {1,2}, {2,3}}; I would like to convert it such that I get the x- and y-values separately, specifically ...
3
votes
2answers
246 views

Weird behavior when changing parts of matrix

I have this matrix: mat = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20}, {21, 22, 23, 24, 25}}; and here are its second row ...
10
votes
8answers
355 views

Forming an upper triangular matrix from the elements of a list

I asked this question before, but i was closed because it the question was not comprehensible enough. So i reworded it, hope that's ok. I have a list with 6 elements. ...
1
vote
2answers
36 views

how to extract a matrix and a vector from a vector [duplicate]

I have a vector like this: V = {a*exp1+b*exp2+c*exp3, a*exp4+b*exp5+c*exp6, a*exp7+b*exp8+c*exp9} and I want to get : ...
2
votes
0answers
100 views

Convex optimization

I am playing with some Compressed Sensing (think single pixel camera) applications and would like to have a Mathematica equivalent of a Matlab package call Convex Optimization (CVX). Specifically, I ...
4
votes
2answers
102 views

Faster Alternative to DeleteDuplicates for deleting elements in list [duplicate]

I have a list in this style data={{a1,b1,c1,d1,e1,f1}, {a2,b2,c2,d2,e2,f2}} I need to delete all elements in which b1 is ...
11
votes
12answers
555 views

How to group each element with each consecutive elements in one head

Suppose I have the following list: list = {a, b, c, d} I want to generate this result: ...
-2
votes
4answers
183 views

Compare elements in a list

Assume that there are three different points in x-y coordinate like: p1={4, -1}; p2={5, -2}; p3={1, 5}; In order to compare these points to each other in a ...
6
votes
2answers
256 views

Apply function to every element of list regardless of depth

I want to apply a function to every element of a list without taking braces into account (depth level), but with the same form of output. Here is an example : ...
11
votes
2answers
303 views

Solving the magic backyard puzzle with MMA

I was trying to solve this puzzle using mma It looks like the generalization of the magic square. Anyway here my attempt:- There are four columns $(x,y,z,w)$ and nine rowa which are denoted by the ...
1
vote
4answers
167 views

Need an efficient way to do this list manipulation

Lets say i have two lists with me as given below: l1 = {4, 6, 8, 9, 10, 12}; l2 = {2, 3, 4, 5, 6, 7}; Now i have a function S2P(details irrelevant) which takes ...
1
vote
4answers
137 views

Minimum and maximum values under conditions

Let's create some sample data ...
3
votes
5answers
137 views

Creating a new list by dropping sub elements of the original list

Suppose I have a nested listed as follows, {{{1,2},{3,4,5},{2,3}},{{2,3,4},{5,4,1},{1,4,3}},{{3,4,5},{3,4,5}}} Where the elements are, ...
2
votes
3answers
124 views

Using select to pick out elements of nested lists in an odd way

Suppose I have a nested list such as, {{{A, B}, {A, D}}, {{C, D}, {A, A}, {H, A}}, {{A, H}}} Where the elements of interest are, ...