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

learn more… | top users | synonyms (3)

4
votes
3answers
336 views

Generate a Combination of letters by a number

I'm trying to write a function f. example: ...
5
votes
3answers
3k views

Local max/min of Mathematica data sets

Is there a way in Mathematica to find the local maxima of a set of points? Suppose you have ...
4
votes
3answers
611 views

Transform a Sum into a List

I want to turn a sum like this sum =a-b+c+d Into a List like this: sumToList[sum]={a,-b,c,d} How can I achieve this?
4
votes
2answers
232 views

How can I use Max[] in a function that is passed a list not find the max of the list

For most functions in Mathematica, passing them a list will call the function on each element of the list. For example: ...
0
votes
3answers
816 views

How to make all values positive?

So I have a list of data that contain both positive and negative values, and I am wondering what I have to do in order to make all the numbers positive.
3
votes
3answers
274 views

How to pull scalars out of a function that should act on lists?

Suppose I have A = a vecA B = b vecB where a and b are supposed to be arbitrary scalars ...
0
votes
2answers
97 views

How to evaluate the sum using values from the data being input

I have a problem in evaluating a sum using values from data I input. Suppose I have data = {1, 3, 5, 6, 8} If I want to evaluate the sum of my data (1+3+5+6+8), I ...
2
votes
1answer
108 views

Specifying form in MemberQ

This seems like a very simple question, the answer to which should be obvious to me. So I won't be offended if this question is closed. But I'm having trouble figuring out the answer. I would ...
1
vote
1answer
346 views

Using 'Reduce' to solve a set of inequalities, specified by a list

I have a two lists $LHS$ and $RHS$, both of size $n$. I want to solve a system of inequalities of the form: $$LHS[1] \leq RHS[1]$$ $$LHS[2] \leq RHS[2]$$ $$LHS[3] \leq RHS[3]$$ $$\vdots$$ ...
2
votes
1answer
118 views

Generating continuous products or sum

This is kind of a continuation of this question. I want to automate these 2 steps on Mathematica once I give an integer $N$. generate a list of variables $\{a_i\}_{i=1}^{i=N}$ then for some ...
12
votes
4answers
1k views

Reshape vectors exactly like in MATLAB

This gives a 64×1 column vector in Mathematica: ...
6
votes
4answers
811 views

Alternatives to While Loops?

I am using Mathematica to run a probabilistic simulation. Essentially, I have a list of members of a population (they only have one, numerical, attribute, so it's just implemented as a list of ...
2
votes
2answers
306 views

Mathematica: summing over n abstract indices

This probably has a one line answer, but I'm totally stuck. I have two tensors, i.e. two objects that depend on NN abstract indices which i've labelled ...
12
votes
4answers
458 views

Calculate proportion of values for dates

At work, we were discussing when is it the best time to change to winter tires for bikes and/or cars. Using WeatherData[] and ...
14
votes
6answers
437 views

Splitting a list by specifying section headers

I have a list of strings called mylist: mylist = {"[a]", "a", "a", "[b]", "b", "b", "[ c ]", "c", "c"}; I would like to split ...
6
votes
1answer
324 views

Find all permutations with reversals / cyclic permutations removed

I have a list of all non-cyclic permutations of n labels. How can I get rid of all elements which are redundant in the sense that they are the inverse of another one. For instance if n=4, the ...
2
votes
3answers
217 views

Maximum tuple value

Is there a simple way to make a maximum tuple value (similar to python)? For example, in python max([ (1,2), (1,3), (3,1), (4,0) ]) returns ...
12
votes
3answers
2k views

Data interpolation and ListContourPlot

I am fairly new to Mathematica and I have two quick questions on using it for a Hydrology and Hydrogeology class. One is about data interpolation and interpolating without any data defined in an area. ...
11
votes
3answers
479 views

Simpler way to fill date gaps with zero values

One basic problem when working with data like sales and dates is the case where you dont't have sales in all days, so you have to fill it to take information as average or to make a plot. See this toy ...
2
votes
5answers
138 views

Test First row of matrix

What is a good way to test the first row of a Matrix to check if one of the values equal a value. For instance, In this example, I want to get vector in the second row that has the bigger value in the ...
2
votes
1answer
129 views

Intersection of conditions

If I have a list of conditions: {cond1,cond2,cond3} and I want to use an If[] statement to test the intersection of these ...
3
votes
2answers
427 views

Dynamically remove element from list based on test

Suppose I have a list l = {a, b, c, d, e, f....} I would like to remove one of each pair {x,y} if some function ...
3
votes
1answer
191 views

How to partition MatrixPlot graphics?

Is there an easy approach - hopefully built-in - to partitioning MatrixPlot graphics into rows or columns (or both) of graphics sharing the same underlying options? ...
4
votes
2answers
437 views

Loop and do operations on Matrix, then graph the results

I'm trying to do some operations to a matrix in a loop, and then I want to graph the results. The results are pair of numbers. Can I store the results of each iteration on "something" and the use ...
1
vote
2answers
96 views

NSum generates a warning message when getting the sum of a list

I know what I'm doing can be done with Total: a = Range@3; Total@a And if I simply choose ...
9
votes
1answer
173 views

Ranking Function Allowing for Ties

I have a list that I need to be able to assign ranks to individual elements in, giving it a number related to its position if the list were to be sorted, allowing for ties. For example, ...
7
votes
3answers
344 views

How to Gather a list with some elements considered unique

I have a list of the form: list={{0,...},{1,...},{1,...},{0,...},{3,...},{3,...},{0,...},{0,...},{5,...},{5,...},{5,...},{0,...},{5,...},{0,...},...} So when we ...
4
votes
1answer
401 views

Splitting a list using SplitBy, by comparing adjacent elements

Suppose that I have the following list called mylist: mylist = {80.2, 80.3, 80.4, 327.6, 327.7, 327.8}; I would like to split ...
2
votes
4answers
275 views

plot data differences

I have the following data: ...
6
votes
2answers
267 views

removing elements that are contained in other elements

For example, I have a list of lists: l = {{a,b,c},{a,b,d},{d,e},{d},{a},{a,b},{f}}; And I want to remove all the lists that are contained in other lists: ...
2
votes
1answer
200 views

How to get the results of Tally split into two separate lists

This is a kind of a followup to my previous question. I am starting with a long list of plane coordinates, like this one: ...
17
votes
5answers
553 views

Map-Thread-Through-Apply a list of functions onto a list of (lists of) values

I have a list of functions: fns = {f, g, h} and a list of triples: ...
6
votes
3answers
203 views

Importing and manipulating strings - time data

I have a list of time durations, which are strings of the form: "hh:mm:ss". Here's a sample for you to play with: ...
6
votes
1answer
244 views

How to compile Map and MapAt

I have a long list (say, million of elements, like this one: {{{1.0, 2.0}, 3}, {{4.0, 5.0}, 6},...} I would like to compile a function ...
8
votes
1answer
213 views

Elementwise, compilable min function

I am trying to implement efficiently a transfer-matrix like algorithm. On each iteration, I have two vectors $x=\{x_1,\dots,x_n\}$, $y=\{y_1,\dots,y_n\}$ with real numbers and I need to compute the ...
2
votes
2answers
142 views

Constraining a random function

This question is a follow-up from here. I have a function that generates a list of correlations between some random variables: ...
4
votes
1answer
214 views

Timing differences between multiple executions of identical code

I have a list of pairs of numbers and I'd like to change the sign of the second element in each pair i.e. $(a,b)\rightarrow (a,-b)$. I'm sure there are many ...
3
votes
2answers
373 views

hexList[[1]] returns a list of decimal numbers

Sorry for not being clear about this question earlier. I appreciate the answers I got, but the edits I made should make the question more understandable. I have been working with hex in ...
1
vote
2answers
211 views

Combining lists with common elements efficiently [duplicate]

Possible Duplicate: Computing the equivalence classes of the symmetric transitive closure of a relation I am required to process sets consisting of 2-element subsets of integers by ...
20
votes
5answers
5k views

How to find the phase difference of two sampled sine waves?

I'm trying to measure a phase difference between two Sine functions I've acquired with a computer. I'm uploading one of the .txt files with the data I'm working with here: txt file. To remove the ...
6
votes
2answers
264 views

Merging different size, different order table

I'm a beginner in Mathematica, so this may be a simple request. I have generated some columns of names and data. I want to merge them into a single list of names, with a column for each attribute. ...
0
votes
1answer
750 views

How to get data from For loops to plot it?

How can I get data from For loops to use in ListStreamDensityPlot? I tried AppendTo, but it ...
9
votes
2answers
239 views

Combining nested lists that meet certain criteria for a permutation

I have the following list representing a permutation on 26 characters: ...
12
votes
1answer
384 views

How to extract and replace submatrix of a doubly-periodic matrix?

How can I effectively extract and replace a rectangular subpart of a toroidal matrix, i.e. one where boundaries are connected at opposite ends? Since the submatrix can overhang the edges, a simple ...
1
vote
3answers
246 views

Replace values of a list containing words and numbers

I'm trying to import some data in a .txt file which contains numbers and words. I import a list which consists of four rows of measured data acquired with an oscilloscope, but the acquisition program ...
1
vote
2answers
220 views

Proper way to deal with lists and map

So, I wanted to do something that I assumed would be really simple. Given two lists, $A = \{a_1, a_2, ...\}, B = \{ ... \}$, I wanted to take a function $f(a, b)$ and generate a list with $\{ f(a_1, ...
6
votes
3answers
320 views

Argmax in a List

I have a sequence of 100 lists. A sample list, list[1], looks like this: ...