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

learn more… | top users | synonyms (5)

1
vote
2answers
117 views

Apply tranformation to particular list elements

I have a list with elements {a -> -1, b -> -2, c -> -3} If I now wanted to apply a tranformation to b and ...
2
votes
3answers
48 views

Assigning sections of a matrix to lists based on row value

I'm working with a very large (4x41355) matrix and I'm trying to make lists out of sections of rows based on the value in the fourth row. It's like this: ...
2
votes
2answers
79 views

Extracting elements from a list in to a new list [closed]

Currently I have a list such that, ...
2
votes
4answers
261 views

How to remove elements from a list that are less than a certain number? [closed]

If I have a list like: list = {23,21,18,15,13,12,10,9,8,7,7,5} How can I remove numbers from that list so that no number less than 13 is on it without hardcoding,...
2
votes
2answers
91 views

Expression in Part[] index

I'm new to Mathematica, and I have a problem with the following kind of code: f[x_] := {1, 2, 3, 4, 5}[[Mod[Floor[x], 5] + 1]] Integrate[f[x], x] When I run this,...
3
votes
2answers
63 views

How do you add one chart to the right of another? [closed]

I have two charts, and I would like to insert the data from one at the end of the other. However, the one chart has multiple ListLinePlots, and when I use Show to try and place the two together, the ...
4
votes
6answers
434 views

Remove the odd element from a list

I have a list, which contains more lists with elements, see example {{1, 1, 1, 1, 2}, {2, 2, 2, 2, 3}, {3, 3, 3, 4, 3}} I want to remove num 2 from the first list ...
1
vote
2answers
87 views

Element-wise join multiple lists [closed]

The following question is related to: Elementwise join I have the following code: ...
12
votes
1answer
283 views

Mapping on leaves

Say I have some nested structure, such as {a,{{b,c},d,{e,{f,g}}}}, and I want to apply a function $q$ to each of the leaves; that is, I want the output to be ...
3
votes
2answers
40 views

List manipulation related [duplicate]

I have two lists l1={a,b,c} and l2={{a1},{b1,b2},{c1,c2,c3}}. What kind of operations can I use to get a list like ...
5
votes
1answer
117 views

How to increase speed of iterations with nonlinear functions

Let me ask about part of a problem which I have in solving of a nonlinear DE (numerically). I am working with vectors of length $xN$. I have an initial vector $v$, a given $xN\times xN$ matrix $A$ and ...
4
votes
1answer
122 views

How to re-assign values to a List of variables?

The accepted Answer to this similar Question can only be used one time, so it's not suitable for my problem. I do high-dimensional calculations for which I need to make lists of variables, like so: <...
2
votes
2answers
85 views

Merge two trees into a rectangular matrix in Mathematica

How can I merge two trees, t and s, so as to form a square matrix below, where both trees starts from top-left (as shown), and ...
6
votes
1answer
220 views

Improving Pop-Up Workspace in Mathematica

Despite the recent improvements to Mathematica's statistical/data analysis tools it still doesn't have a built-in workspace interface for organizing and interacting with user defined variables/...
1
vote
0answers
79 views

Lower memory usage and speed nested loops

I'm trying to make some tracking with Mathematica. ...
7
votes
3answers
238 views

Deleting any list that contains a negative number

We had another nice question in a student activity today. The increasing sequence of positive integers $a_1,a_2,a_3,\ldots$ has the property that $$ a_{n+2}=a_n+a_{n+1} \text{ for all } n\ge 1. $$ ...
5
votes
3answers
414 views

How to calculate a list without loop?

I have pairs of numbers {a1, b1}, {a2, b2}, {a3, b3}, ..., ...
10
votes
7answers
268 views

Extract left-upper triangular data from a square matrix-form list

Hopefully, this question is not too basic or obscure. I'd like an idea on how to extract this {{1}, {5, 2}, {9, 6, 3}, {13, 10, 7, 4}} from ...
1
vote
2answers
117 views

A better way than using nested For-loops to make a search list

I'm generating a List that can be up to 26 values long, a simplified example is below. Is there a better way than nested loops? ...
4
votes
0answers
53 views

How to transform a tree-form list to matrix-form list in Mathematica? [closed]

Excuse my naive question. Is there a quick/efficient way to transform {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}} to a lower-triangular matrix-form ...
1
vote
5answers
390 views

How to repeat a string?

I really can't find a way how to multiply (repeat) strings in Mathematica. How to write this shorter? ...
2
votes
2answers
73 views

Problem with ArrayFlatten to concatenate matrix

I would like to concatenate 2 matrix : - the first which is a line of 2 elements - the second which is a matrix of 2-2 elements I use the following code : ...
1
vote
1answer
55 views

Problem averaging multiple series of data [duplicate]

Recently I'm having trouble figuring out a certain problem in Mathematica. I have a table of data in the following arrangement: {series no., x, y} Now, each series of data has exactly the same x ...
0
votes
2answers
62 views

Numbering the elements of a list

From a vector q={Gamma,x,y}, I would like to create the following corresponding list : qn={1,2,3}. Other example, if I have <...
2
votes
1answer
55 views

If I want a function only applies to the elements of a specific list, how should I define the function? [closed]

If I define a list: list={1,2,3,4}; and I want a function f to apply only to the elements in the list (for here it is 1,2,3,4)...
27
votes
3answers
509 views

Cyclic Take function? [duplicate]

Is there some direct and simple "cyclic Take", sometimes also known as "overtake" in Mathematica. That is, if the take specification runs out of elements, it just cycles back to the beginning (as many ...
4
votes
1answer
52 views

apply a constraint to summation limits

I have a list as list={{-0.5, 5}, {-0.25, 2}, {0, 3}, {0.25, 2}, {0.5, 5}} and I want to use of Esc+sum+Esc symbol for ...
8
votes
1answer
95 views

Understanding Part and Span operating on expressions with heads that are not List [duplicate]

I hope this is not a duplicate. I do not understand how does the Part and Span functions work on this expression: ...
6
votes
3answers
162 views

Determining closest lists near any selected point

I'm plotting several lists of data (constant lines of density, temperature quality, etc. on a pressure-enthalpy diagram), none of which are fitted well by ...
27
votes
4answers
1k views

How to implement the general array broadcasting method from NumPy?

A friend of mine introduced array broadcasting in the Python NumPy package which is very convenient (and also highly efficient). The idea is perfectly shown in ...
10
votes
1answer
153 views

Is there an efficient way to load a large list to Mathematica from R within Rlink?

I'm working on something that involves using both R and Mathematica. For this something, I first generate a large R list (1000 matrices, each 200x1000, mixed integer and real values) and then need to ...
2
votes
2answers
61 views

Reflect manipulations on one list in a second list

I'd like to mirror the manipulations (specifically deletion, insertion, and reassignment) done at each position of two equally-sized lists, based on the contents of only one of those lists. As an ...
4
votes
1answer
75 views

How can I get all pairs of values from an association with elements key->list

I have an association of the form ds=<|key1 -> list1, key2 -> list2,... ,keyn -> listn|> I would like a simple way to map a function to all pairs <...
1
vote
1answer
75 views

Using Select function based on data range

I am using Select to take values from a multidimensional list based on a previously calculated range. The list is of time and position of a particle over time steps done for multiple particles. The ...
3
votes
2answers
124 views

Customized ListPlot

I have an external data file containing the elements (t,x,y,px,py) of an orbit. Here is a sample data file. Now I want to ...
5
votes
2answers
345 views

Smallest element distance between two lists

I have a problem, where I generate two lists of points, and I want to see which points are the closest. If I just want to find which ones are exactly the same, I can use ...
1
vote
3answers
248 views

Command like “find” in Matlab [closed]

Is there a command working exactly like Matlab's find? I know that Pick might work, but I just want to give a logic condition ...
1
vote
2answers
196 views

How to speed up a For-loop [closed]

My code is the following: ...
3
votes
1answer
77 views

Who can explain the strange behavior of command “Last”

Situation I use Last to extract the last element of an expression. Let poly=a+b*c+Log[a]+z. Problem When Using ...
4
votes
3answers
141 views

List of functions to list of parameters

I am working in a Dataset and I need to create a function for a ChartStyle option of a ...
4
votes
1answer
76 views

apply binary operation to all adjacent pairs

Is there a built-in or more efficient approach than using Partition to apply a binary operation to adjacent pairs of elements? That is, is it reasonable to be ...
7
votes
4answers
153 views

Reverse DeleteDuplicates using Information from Tally

I have a list of values, e.g., {1, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 5}. I delete the duplicates with ...
3
votes
3answers
132 views
3
votes
0answers
58 views

Problem with MissingDataMethod [closed]

Given v = {2, 1, Missing[], 5, 7, 4}; I use EventSeries to replace the missing value with its predecessor ...
4
votes
3answers
137 views

Inserting an indexed string into the 1st position of each pair in a list of pairs

How do I insert "Z" and then a number going from 1 to end (without space) in a list? I have the following list: Input: ...
1
vote
2answers
54 views

Bin data from an imported excel file by adding 5 elemets of y axis each [closed]

So i imported a file from excel and viewed it as a grid. but now i need to add groups of 5 elements from the y axis and plot them against every fifth entry from the x axis. Thanks Edit: Sorry about ...
1
vote
2answers
117 views

Trouble adding elements to array [closed]

I need to generate array and export it to file. For n = 1 , second element must be 0 For n = 2.. 819, second element must be 1 For n = 820.. 1637, second element must be -1 For n = 1638.. 16384, ...
1
vote
1answer
69 views

Filter two lists of 2D coordinates such that only those that have a nearby neighbour in the other list are collected

I have two sets of coordinates: GreenPairs.xls RedPairs.xls I'm only interested in the coordinates that have a very close (overlapping in the plot below) different coloured neighbour. The ...
3
votes
2answers
320 views

DeleteCases In Mathematica

I want to eliminate all the sub lists containing exactly two positive numbers? My list is ...
3
votes
1answer
57 views

FindLinearRecurrence is not working for numerical complex number sometimes?

First FindLinearRecurrence definitely support complex number list, see ...