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

learn more… | top users | synonyms (3)

8
votes
4answers
281 views

Complement of multisets

Given lists $a$ and $b$, which represent multisets, how can I compute the complement $a\setminus b$? I'd like to construct a function xunion that returns the ...
2
votes
1answer
45 views

Complement for a Matrix

In a matrix, there are some non-zero elements same as: aA= Also, there is a list such as: list = {a, b, c, d, e, f, g, ii, jj, kk}; I want to access to ...
3
votes
2answers
177 views

make a list based on two other lists

I have two lists: list1={4,6} list2={1,2} and I now want a function f that produces f[list1_,list2_]:={1,1,1,1,2,2,2,2,2,2} ...
1
vote
0answers
35 views

A more efficient way of fitting a non-linear model that returns an entire list?

I have a function that takes two parameters, del and nu, and returns a list npoints long ...
4
votes
3answers
377 views

Efficient matrix / array generation

What is the most efficient way of generating the following matrix? $\left( \begin{array}{ccccc} 1 & 0 & 1 & 0 & 1 & 0 & 1 & \dots\\ \frac{1}{2} & \frac{1}{2} & 0 ...
0
votes
1answer
75 views

how to apply a function to a list of tables

I have several files, and I want to extract for each of them a table, and then select just numbers, and keep only rows with five elements. My code works fine during import ...
2
votes
2answers
92 views

select from a list based on digits

I wish to know how do I count the number of occurrences of numbers that end in digits d. e.g. Say I create a list of Divisors of 12! I now want to count those divisors that end in 12. Like 12 & ...
0
votes
2answers
135 views
0
votes
2answers
90 views

How do I perform the riffle function backward? [duplicate]

I know riffle will combine the lists {1,2,3} and {a,b,c} to be {1,a,2,b,3,c}. Is there a way to work backward and split the list {a,b,c,d,e,f} to be {a,c,e} and {b,d,f}?
8
votes
2answers
349 views

Aligning two lists

I have two lists, L1 and L2, each with a key and some data. Let us say the key is a person's name, a string, and the data follows. (To respond to rasher's query:) Let us also assume the lists are ...
1
vote
2answers
139 views

position of element in a list using a function

How can I find in a list l the positions of all elements satisfying a boolean function f. For example, how can I pick in ...
3
votes
6answers
318 views

How can I construct a distance table?

I have a list of city names (of arbitrary length), f.e. c = {"BAL", "NYC", "LAS", "AUS"}; and the distances between them : ...
1
vote
2answers
153 views

Find equal elements on a list

Consider the following code to produce the sequence $x_1,\ldots,x_{n+1}$ where $x_i=11\cdots1$ ($i$ digits 1). Is there an easier way to do this? ...
2
votes
1answer
91 views

How to find all possible correlations between n vectors

Given the Matrix ...
0
votes
1answer
54 views

Taking Mean for several elements of a list [duplicate]

i have the following question: Let us assume we have the following list: list={1.1,1.2,1.0,2.1,2.2,2,0,3.1,3.0,3.2} I need a function that always takes three ...
1
vote
3answers
123 views

Working with nested matrices

I have a matrix: A = {{a, b}, {c, d}} But each its element, itself, is another matrix too. ...
0
votes
1answer
146 views

How to load data into a Manipulate expression

I have data showing truncated octahedron geometry changing with time. How can I read those data into a Manipulate expression? To be specific, I want to manipulate ...
0
votes
1answer
40 views

Testing a certain function over multiple levels

I regularly want to test if a certain function, here foo, gives the expected result when mapping it over n - level - matrices. My naive approach is to write: ...
0
votes
1answer
64 views

Swapping rows and columns in matrix [closed]

If I have an array like the following $\left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{array} \right)$ How can I swap the rows and columns, so it is ...
0
votes
2answers
164 views

How to pass a list as function argument?

I have the following function lFreqPhylo[a_, Q_, b_, p_] := Sum[Log[freqFunction[r[[p]][[i]], L[[p]][[i]], a, Q, b, {i, 1, nbranches[[p]]}]; The objects L, r ...
0
votes
0answers
28 views

Unexpected results from Thread [duplicate]

I've run into an issue where threading two lists with a generic function, f: Thread[f[{{1,1}, {2, 2}, {3, 3}}, {4, 5, 6}]] ...
2
votes
1answer
175 views

Is there a better way to create my rotational-symmetric (180 degrees) rectangles?

I have created a simple way to create rotational-symmetric (180 degrees) rectangles, but my stuffit function bothers me. No matter what I tried, I couldn't get it ...
0
votes
1answer
74 views

Help with DeleteCases [closed]

Trying to delete small elements from a list with copy = DeleteCases[copy, {y_} /; y <= 1500.0 ] but it does not work.
0
votes
1answer
66 views

Apply function to output of previous function

I am trying to write a function that takes 3 tuples. Each tuple contains two lists which are first divided. This results in 3 lists. Then I want to take the Mean of all the columns. I can do this ...
1
vote
1answer
80 views

Matrix and string variable

There are $100$ .dat data files which contain numerical parameters. ...
1
vote
1answer
59 views

If statement and elements of an imported data

I import a data file: SetDirectory["C:\\Users\\SE7EN\\Desktop\\mathematica\\test"]; dd = Import["data.dat", "Table"] Out[2] = {{1}, {2}, {3}, {4}, {5}, {6}, {7}} ...
0
votes
1answer
53 views

Manipulating lists with constant values [duplicate]

let us assume we have some data in the following form. Table[data[[1,i,{1,2}]],{i,1,Length[data[[1]]]}] This would give all $x-y$ pairs of the first file. What I ...
1
vote
1answer
77 views

How to find the maximum values and the place of the max value in the list? [duplicate]

I have given an example to find the maximum value and its place in the list. Is it possible to find the local maximum in the sub-list of this list means local maximum in the each row of the list and ...
3
votes
0answers
78 views

Why does Part behave like it transposes lists? [closed]

From the documentation of Part: Part[expr,i,j,...] is equivalent to expr[[i]][[j]]... ...
3
votes
2answers
103 views

Converting unevaluated lists to strings

I have a list like l = {2 - 3, 12 - 4, Times, aab} I want to end up with {"2-3", "12-4", "Times", "aab"} I have tried ...
8
votes
1answer
113 views

Strange behavior of BinCounts

Just try this example: ...
2
votes
2answers
127 views

Building adjacency matrix from set data

I have two sets: games and players. Players pick their games. As such I will have data say g1={p1,p3,p5},g2={p2,p4},g3={p2,p3,p5}. My interest though is to build the connections among players because ...
4
votes
1answer
144 views

Selectively converting numerical strings to expressions

I have a list of strings representing different types of data ...
1
vote
1answer
47 views

Grouping Nested Lists Based on Differing Values of Single Element

I've a list of lists representing k-rows of truth table having n elements each in a nested list consider ...
0
votes
1answer
45 views

Generating list of functions from list of expressions

I know how to create a function from concrete expression like Function[{x, y}, x^2 + y^2] But what if I have a list of expressions list1 and I know the set of ...
1
vote
2answers
75 views

Manipulate which creates and deletes Manipulators dynamically

I want to plot a function in a Manipulate in which the number of terms varies and a Manipulator for the coefficient of each term ...
0
votes
1answer
86 views

Select positive value from a vector

I am wondering how to pick out the positive Omega value from soln, and make these positive values into a row vector. I know how ...
0
votes
1answer
65 views

How to discriminate Weatherdata latitude and longitude from a more detailed list

From this list of weather data how can I discriminate only latitude longitude for each station? For example from the following sample I would need only the coordinates: "50136","","Aoluguya|Mohe, ...
1
vote
2answers
106 views

How to drop the identical rows and columns of a matrix?

I'm currently trying to find a way to eliminate from a square matrix of generic dimension the duplicate (up to sign) rows and columns, obtaining a smaller dimensional matrix. I searched around here ...
0
votes
1answer
94 views

How do you add options to a function that is being mapped?

Simple example: Normally: ListPlot[list, Joined->True] If I want to map ListPlot how do I keep the ...
1
vote
2answers
128 views

From a list of (x,y) pairs, generate a new list of (x,ymean) pairs, where ymean is the average of all y's with the same x in the original list [duplicate]

This seems like the sort of thing where Mathematica can give a very simple solution. I have a list of points {x,y}: ...
0
votes
2answers
75 views

Merging two lists by prepending elements

Being a newcomer to Mathematica, I have the following question. Given x = Range@9~Partition~3; and y = {a, b, c}; I want ...
1
vote
1answer
70 views

How can I get a certain kind of iteration? [closed]

Can I get this type of do-loop in Mathematica? Do[Print[j," ",k," ",l], {j,k,l, {a, b,z}, { c, d,y} }] I want this to work so that, in the first iteration, ...
0
votes
1answer
82 views

ListDensityPlot with discrete bins [duplicate]

We consider a table of the form data = Flatten[Table[{i,j,f[i,j]},{i,1,ni},{j,1,nj}],1] The function f[i_,j_] has been made ...
2
votes
0answers
68 views

ParallelTable and expensive functions

I would like to build up a 2D-Table using ParallelTable as follows ...
0
votes
1answer
58 views

How to take single item out of List? [duplicate]

I often get Lists that contain a single item, like {name} or {{2,3,4}}. Is there a function ...
2
votes
2answers
106 views

Extracting “records” from a matrix

From a rank 3 matrix like ...
4
votes
2answers
263 views

What is the Mathematica way of joining two tables?

Is there a special Mathematica way of joining tables of data together, so that I would get similar functionality as if I was running a database with sql? For example, I have one particular table ...
1
vote
1answer
54 views

Componentwise Addition of TemporalData

I'm a little confused with the TemporalData structure in Mathematica, in the sense that it doesn't seem to behave like a list. What I'd like to do is plot the sum ...
0
votes
1answer
75 views