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

learn more… | top users | synonyms (3)

0
votes
2answers
85 views

Code for sum of exponential divisors function

Consider $n = p_{1}^{a_1}\cdots p_{r}^{a_{r}}$. An integer $d = p_{i}^{b_{i}} \cdots p_{r}^{b^{r}}$ is called an exponential divisor of $n$ if $b_{i}$ divides $a_{i}$ for every $1\leq i \leq r.$ I am ...
1
vote
1answer
107 views

How to apply compiled function on list

Compile function output error: How to apply compiled function on list? ...
2
votes
1answer
71 views

Convert Integer to Numeric with Replacement rules

I have a long list of triples, each looking something like {AGO, 1988, 2345.23}. Some of these, however, have an integer in the third spot, like this: ...
1
vote
0answers
134 views

Using Part within a Compiled Command

I'm looking to define a multi-line function that makes use of the "Part" command. A toy example: ...
1
vote
0answers
69 views

Produce {f[x],g[y],h[z]} in as many ways as possible [duplicate]

I have two lists of equal lengths but for my task I will use 3-element lists , namely {x,y,z} and {f,g,h}. The first contains ...
1
vote
2answers
110 views

Add a column to a matrix as a function of the other columns

I was wondering if its possible to add a column to a matrix by a formula that uses all other columns, like this: ...
0
votes
3answers
468 views

Find the number of nonzero elements

How do you find the number of elements in a matrix that are non-zero. For instance, the following matrix has 5 nonzero elements. ...
0
votes
1answer
188 views

Performing matrix multiplications with a list

I have a question in regards to PseudoInverse. I have $A$, an $n\times 2$ matrix, and when I want to compute $(A^T A)^{-1}A$, by using ...
6
votes
2answers
118 views

Get brief help for a set of functions

When we are in console mode or working with a notebook we can get brief help about a function just by shift-entering ?function I would like to have a list like ...
4
votes
2answers
2k views

How to combine two vectors into a matrix by columns?

I know it may sounds idiot, but I've been looking through the document, and couldn't find a way to combine two vectors say {a, b} and ...
3
votes
3answers
283 views

efficient way to give nearest neighbour and next nearest neighbour of every point in a point set

Suppose we have a point set, the points are labeled 1,2,3,....n. And p[i] is the coordinate of the point. Now I want the label of nearest and next nearest point ...
0
votes
0answers
43 views

Store results of inequality [duplicate]

I eveluated some values using Reduce commend and I store them in a Table ...
8
votes
7answers
682 views

How to partition a list in a specific way

I have a list: a = {{1, 2, 3, 4, 1, 2, 3, 4}, {5, 6, 7, 8, 5, 6, 7, 8}}; Using Partition and ...
17
votes
9answers
920 views

How to replace an element in a list based on the value of the next element?

I use Mathematica a little bit. I try to understand it, but it is hard I have a list of 5 numbers selected randomly from 0 and -1. I have to replace a 0 with a 1 when the 0 is followed by -1. My ...
4
votes
1answer
147 views

Efficient ways to rotate a ListPlot?

I have a numerical solution from a differential equation that is in the form of a list, in $(x,z)$-plane. I would like to rotate the 2D ListPlot around the $z$-axis ...
11
votes
10answers
515 views

How to pick increasing numbers from the list

How to pick increasing numbers from the list. lst = {5, 3, 6, 2, 7, 4, 8}; out: {5,6,7,8} So many interesting ...
5
votes
6answers
278 views

Convert array from {{…}} to “[[…]]”

I have made this function: conv01 = Map["["<>StringJoin@@Riffle[#,","]<>"]"&,Map[ToString,#,{2}],{0,1}]& to convert: ...
0
votes
1answer
108 views

How to create 2k sized vector in k sized loop

I want to solve a system of simple differential equations. At some point I need to solve non-linear system of algebraic equations with Newton method. I would like to efficiently create a right hand ...
6
votes
2answers
178 views

how recover lost data of coordinates from contourplot of mention data?

I have made Contour Plot for a lot of data, like this ...
1
vote
2answers
106 views

How to return matching sublists or empty list

How to return matching sublists or empty list m1 = {{1, 0.5}, {2, 0.4}, {3, 0.1}}; m2 = {{1, 0.5}, {0, 0.4}, {0, 0.1}}; Commonest[Join[m1, m2]] out: ...
2
votes
2answers
163 views

Organise data in table

I have a large amount of data available (in excel), which is not very organised. I can do this by copy paste, but I am trying to do this using mathematica. Hopefully someone can help me. I imported ...
-2
votes
1answer
79 views

Using Product for different variables

when using product in mathematica the initial and maximum value of the product will be the variable itself that will be maupulated. what I need is to make these initial and maximum of the product as ...
3
votes
2answers
211 views

How can I scale the y axis?

I have a file I import and read into a table of $2 \times n$. I can plot this data using the following code: ...
1
vote
3answers
210 views

Code hanging inside a For loop

I'm pretty new to Mathematica (and functional programming in general). I'm working on some code to find winners (maximal values) in a list. The code I have that is hanging is this line. ...
4
votes
2answers
131 views

Coordinates for multiple countries

I am trying to plot polygons for multiple countries, say "UnitedStates" and "Canada". US data is generated thus: ...
8
votes
8answers
354 views

How to use Map inside MapThread?

Given this input lst1 = {{a, b, c}, {d, e, f}}; lst2 = {1, 2}; and the goal is to generate this output ...
15
votes
2answers
1k views

Is there an equivalent to MATLAB's linspace? [duplicate]

Does Mathematica have an equivalent to Matlab's linspace? I want to make a list with "start", "stop" and "number of points". What is the neatest way of doing this?
3
votes
6answers
262 views

Compute ratios of elements in two lists

I have two lists, say a and b, both of length n. I'd like to compute the following: ...
2
votes
2answers
74 views

How can I generate a variable-length list of options in PieChart?

I would like to allow a user to manipulate the segments of a pie-chart, which is to be generated from a list of a specific format. The code looks something like the following: ...
11
votes
4answers
544 views

List comprehension in Mathematica

Python supports a concept called "list comprehensions". Following is sample example ...
13
votes
11answers
786 views

How to get list of duplicates when using DeleteDuplicates?

This might be easy, but can't find a way to use DeleteDuplicates to get also list of the actual duplicates. Example: ...
0
votes
0answers
63 views

How to delete duplicated sublist [duplicate]

I have a list like this: ...
-1
votes
2answers
217 views

How can I extract when a select condition is met in a do loop the value of the iterator?

I use the following code to find out the number of consecutive prime numbers using a formula $n^2+n+i$ found out by Euler (starting from n=0): ...
5
votes
6answers
182 views

Reversing every second “row” in a list

I have a list that is obtained by flattening a matrix list=Flatten[Table[{i, j}, {i, 1, 4}, {j, 2, 6, 2}], 1] {{1, 2}, {1, 4}, {1, 6}, {2, 2}, {2, 4}, {2, 6}, ...
12
votes
4answers
339 views

How to enumerate all possible binary associations?

Suppose I have a list of symbols like: {a,b,c,d} I would like to enumerate all possible binary associations (combining symbols and/or sublists pairwise): ...
0
votes
3answers
95 views

List of squareful, cubeful, etc. numbers

The following works: ...
4
votes
2answers
117 views

How to constrain the generation of all possible orderings?

Here is code from Simon Woods' answer for getting all possible weak (equal ranks allowed) orderings for $N=3$ objects: ...
1
vote
2answers
165 views
11
votes
7answers
379 views

Concatenation of lists in a Fibonacci-like pattern

I am trying to create a List of elements that follow the general pattern: $$X_{n+1} = X_n X_{n-1}$$ where the operation on the right hand side is concatenation, i.e., joining. I want to achieve the ...
0
votes
3answers
92 views

How to get the indices of values in a list which are NOT an specific integer?

I got a real array A, where Dimensions[A] == {5000, 5000, 5}. Some of the values in A are ...
4
votes
2answers
171 views

How to insert / merge a list into another list?

Background: I am working on a 2D geometry algorithm where I need to insert a list of 2D points into another list of 2D points. Somewhat to my surprise I found no Mathematica function capable of doing ...
11
votes
3answers
338 views

How can I remove the singleton dimensions of an array? [duplicate]

If I have an array A, for which Dimensions[A] is {9, 9, 1, 1, 3, 4}, how can I convert ...
3
votes
2answers
317 views

Filtering and Replacing outliers

I have a set of data that measurements of temperature vs time (date). It is easy to realize when the sensor went wrong as one might see a blip on the data. How to teach to Mathematica to: 1) Detect ...
2
votes
2answers
120 views

Interpolating a list with exclusion [closed]

I have a list, data, where the elements data[[i]] range over i from ...
2
votes
5answers
178 views

How do I find the maximum value from the given set of data?

I have a set of data like {{x1, y1},{x2, y2}, ...,{xn, yn}}. From this data can I find the value of x for which ...
0
votes
1answer
81 views

Use a pre-computed list instead of RandomInteger

I would like to replace RandomInteger[{1, 10}, {10, 10}] in the following code: ...
5
votes
2answers
181 views

Interactive grid

I would like to create an interactive grid, whereby one number from a grid is selected by the cursor ("3" in the example below), and all other numbers in the grid are highlighted that are related to ...
0
votes
2answers
136 views

Combining graphics & lists / tables

I have: created with: ...
1
vote
1answer
112 views

How can I pass in parameters for multiple controls to a function that returns a Manipulate?

For instance, I have a some "commands" that I use regularly, for example: ...
0
votes
1answer
130 views

Interpolation problem on the list

I have a List of Latitude, Longitude and Measurement. a = {{{93, 104}, 290}, {{94, 103}, 292}, {{95, 105}, 291}, {{97, 109}, 294}, {{97, 102}, 295}}; And, I ...