Tagged Questions

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

learn more… | top users | synonyms (3)

1
vote
3answers
98 views

Creating Graph with two or more values in second column

For a social network analysis I have two columns. The second column has one, two or more values. Something like this: ...
2
votes
1answer
77 views

Using Total on a list supplied by a rule

I'm confused as to why Total complains about a nonatomic expression here: ...
1
vote
1answer
83 views

Selecting items in a list based on multiple tests

I have an array of strings that look like this: ...
2
votes
3answers
154 views

Wrapping a data selection in Mathematica

I was wondering what would be the most efficient way to add brackets to given elements in my data set in order to change it's form from {{a,b},{c,d}} to {{{a},b},{{c},d}}. I took a look through a few ...
1
vote
1answer
428 views

Finding the position in a list where the maximum or minimum value occurs [duplicate]

We can use Max[exampleList] or Min[exampleList] to find the maxima and minima of ...
1
vote
1answer
93 views

Need help defining my own rounding function

First of all: I'm a beginner with Mathematica. I'd like to define a function called Rounding which does the following: if for $x = n+a, n \in \mathbb{N}, a\in ...
10
votes
3answers
534 views

What is the most efficient way to map a linked list?

In order to work with lists effectively using common recursive patterns from functional programming, it's often most convenient to worked with the "linked list" representation, that looks like this: ...
0
votes
0answers
458 views

Nested for loop in mathematica

I have a code in mathematica with a loop which iterates over a variable i and calculates a list of numbers h given the start parameter f: ...
1
vote
1answer
46 views

Padding sub-lists in a list [closed]

I have a list, say `Alist`` Alist = {{1}, {2}, {1, 3}, {4, 5, 6}, {4}}; and want a list, Blist such that ...
3
votes
1answer
269 views

Select row from a table by column value [duplicate]

I have the following: animals = {{dog, black, 200}, {cat, white, 100}, {moose, brown, 500}, {zebra,black,100}} If this came from a SQL table called animals, ...
2
votes
1answer
92 views

Restoring the 1-to-1 correspondence between elements in two lists, where one list is used as a guide to prune elements from the other

when we wish to use one list to select items from another using something like Pick, writing the following code, for example, causes us to lose the 1-to-1 ...
1
vote
2answers
144 views

MapThread with List Manupulation

I have the following three lists: ...
2
votes
2answers
512 views

Index-based Array splitting

I have an array of arbitrary elements, say strings: testArray = {"String A", "String B", "String C", "String D", "String E"}; How can I split this into two ...
3
votes
1answer
173 views

Social Network Analysis - Get the End Points of an Edge

I want to get the end points of an Edge of a Graph. For example see the following source, ...
1
vote
1answer
120 views

How to replace a list with the result list after each iteration [closed]

I have some initial values such as L1 list: L1={10,20,30,40,50}; I want to use the L1 ...
0
votes
1answer
155 views

How to prepare (copy/paste) data from Matlab?

What is the best way to get data from Matlab to Mathematica? For a new project I want to copy/paste a table (or part of it) of datas from Matlab to Mathematica. Copyed from Matlab it is: ...
0
votes
2answers
61 views

How to obtain all the partitions in a set $A$ such that the union of these partitions equals $A$?

I'm trying to make a visual proof on the irrationality of $\sqrt{2}$. At the moment, I've created a figure to show that $b^2$ elements always constitute a square: And I want to show that it's not ...
0
votes
1answer
109 views

Advice on Gather

Is there a better way to write this gather? I have a list of particles, "particlelist", and a list of particle coordinates, "coordlist" and I want to put all the particles into a 3-dimensional ng x ...
1
vote
2answers
490 views

Research positions of lists of varying size

I'm new to the site and I am French, so I ask your indulgence for my future mistakes in English. I would like to optimise the following code : ...
3
votes
3answers
211 views

Finding a better way to define a matrix

I first defined a 171x171 matrix containing only zeros and then replaced 18 specific rows with nonzero entries. The other $153$ rows will be average of $2$ of the existing $18$ rows. Rows $2$ ...
0
votes
1answer
76 views

Running function - updating list - run function etc

I am making a larger program, so I would prefer to give a short example of my problem: ...
0
votes
1answer
111 views

Index of iteration inside NestList [duplicate]

I have a list of RandomReal: delta = RandomReal[{-0.01, 0.01}, 1000] I want to add each element of the list to the ...
1
vote
3answers
180 views

How to update a list in a function in each iteration

There is a list with numbers 1 to 8 ( p1 ) and another list (j) which contains 4 numbers which shows different 4 positions of ...
2
votes
1answer
71 views

Identifying and isolating sections of overlap in a set of integer intervals

I have a very large array like the following: {{1,10},{8,9},{9,20},{34,40},{41,42},{43,50},{47,53},...}; Now, imagine that every element in the array corresponds ...
5
votes
1answer
164 views

How to combine matrix with array without cycles?

I am new to Mathematica. And I'm sorry for my English. I have created a matrix ($6 \times 4$) and an array ($1 \times 4$). I want to get another matrix that will have the first element from the array ...
1
vote
3answers
194 views

How to replace identical positions in two different lists

Assume that I have two lists like : list1={1,2,3,4,5}; list2={a,b,c,d,e}; I want to replace some elements from list1 into ...
0
votes
0answers
70 views

Optimization of vector manipulation

I'm trying to implement an upwind scheme for solving transport equation (at first, I work with no right hand side and the simpliest case possible - velocity is constant, initial data is smooth, etc). ...
1
vote
1answer
240 views

How to find the local maximum of a list [duplicate]

I have imported a wav sound that a = Import["sound.wav"] and we know that soundStrength = a[[1]][[1]] is a list of sound ...
2
votes
3answers
167 views

Extracing information from a table

I am new to Mathematica. I have created a table of real numbers. I want to create a new table that contains the set of values of $i$ such that, in my original table, the $i$th entry is greater than ...
2
votes
0answers
147 views

Faster Ways to compute recursive summation

It takes a long time to compute the summation below, and I'd like to know if there are some better ways to compute things faster. I have used $3$ ways to calculate, but they are very unsatisfactory. I ...
11
votes
2answers
199 views

Bug with SparseArray selector in Pick

I have created a notebook with two cells. This is the content of the first: ...
1
vote
1answer
86 views

Matching variables with Subscripts yielding True and False

I am trying match variables with subscripts just returning true or false depending if pattern is matched. My try is to use Cases. However the following does not ...
0
votes
0answers
36 views

Number precision in a list [duplicate]

I have list with elements: ...
5
votes
5answers
343 views

Joining some strings in a list of strings

So, say I have a list of strings, representing lines in a file, like so: ...
0
votes
2answers
110 views

How can I select elements that are true

I have a list of lists. For example, list = {{0,1,0,1,true},{0,0,0,0,false},{0,1,1,1,true},{1,1,1,1,false},{2,2,2,2,false}} I'd like to find all lists that ...
2
votes
2answers
109 views

adding vectors of unequal length [duplicate]

If I have hundreds of vectors of unequal length that I need to sum, what is the cleanest way to do so? So, if I have as input inp={{a,b,c,d},{e,f,g},{h}} I want ...
0
votes
2answers
131 views

Apply Eigenvalues to a list of matrices

I would like to apply Eigenvalues[] to a list of matrices as in the following ...
19
votes
3answers
821 views

How to extract the edge from a set of points

I have an accumulation of points representing a body as you can see in the image below. From this data I want to generate a list of points or a curve, which is the envelope. The first idea was a ...
0
votes
1answer
97 views

Populating an array with outputs of a function [closed]

I have searched, but didn't find much help on my issue. I have an optical physics problem that I'm working on .. ...
2
votes
2answers
163 views

list of vectors with prescribed sum

Let $a\in\mathbb{N}^n$ and $k\in\mathbb{N}\!=\!\{0,1,2,\ldots\}$. How can I efficiently generate the list $$\{(a_1,\ldots,a_k); a_1,\ldots,a_k\!\in\!\mathbb{N}^n\!\setminus\!\{0\}, ...
4
votes
4answers
343 views

Efficient method for Inserting arrays into arrays

This is strongly related to the following Questions: Looking for a way to insert multiple elements into multiple positions simultaneously in a list Building matrices by attaching vectors (columns) ...
1
vote
2answers
76 views

How to switch between a binary number as String and a as a list of digits?

I was trying with String Functions and I viewing any posts and have no results I want to know 1.- From cromo33 = Table[RandomInteger[], {i, 1, 33}] cromo33 ...
3
votes
2answers
245 views

Mapping multiple functions over an array

I am looking for an elegant way to Map multiple functions over an array. My problem looks something like this: Consider a list of functions: ...
0
votes
2answers
144 views

Summarizing SQL Tables

data = Table[SQLSelect[conn, "All", {"col1", "col2"}, SQLColumn["col1"] == n && SQLColumn["col2"] == o], {n, 1, 8}, {o, 21, 30}]; This results in ...
3
votes
3answers
247 views

Data Table Manipulation

Suppose that I have the following ...
2
votes
2answers
235 views

Removing trailing zeros from a list

If I have a list like list1={2334.,342.,0.,0.,2322.,0.,0.,0.,0.,,,,,,}; it's easy to remove to trailing blanks with ...
4
votes
2answers
120 views

Values (or positions) of array row elements within a specified number of positions from target value

I have the need to collect values from the rows of rectangular arrays of arbitrary precision integers, given a target element value and allowed "distance" (positions +/- within the row from found ...
2
votes
4answers
503 views

More elegant way

I read ReplaceOrRemoveInvalidOrMissingData Mathematica documentation, and I tried to apply the same approach to my dataset. I've got two problems, but one is only a style problem! There is one more ...
0
votes
1answer
143 views

Problem ListLinePlot with 2 data sets [closed]

I am trying to plot 2 data sets with ListLinePlot and my problem is that no graph shows up. When I plot a single data set i.e. ListLinePlot[Aluminium] it looks ...
0
votes
3answers
97 views

Function to naming columns

I often import files from excel or csv files and they come in a format like this: ...