-2
votes
4answers
162 views

Compare elements in a list

Assume that there are three different points in x-y coordinate like: p1={4, -1}; p2={5, -2}; p3={1, 5}; In order to compare these points to each other in a ...
5
votes
5answers
430 views

Populate an upper triangular matrix from a vector of elements

What is the best way to populate an upper triangular (or alternatively: lower triangular or symmetric) matrix from a vector of elements? This example input: ...
0
votes
1answer
46 views

Help with programming(using list) [closed]

I would like to make a program which gives me what is the greater natural number "n" less than an arbitrary given natural number "k" which satisfy: for each prime divisor "p" of n, p^2-1 divides n. I ...
0
votes
0answers
53 views

deleteduplicates Delete elements of a list [duplicate]

I have a math problem about Mathematica, I am looking help from you. I hope that you could help me. The Math Problem: list= { {0,0,1},{1,0,0},{0,1,0} ,{1,2,3}}; ...
1
vote
1answer
52 views

Elements of a List according position in axis

({{a, b}, {c, d}}) a, b, c and d are Lists of 300 length. Their first 4 elements must specify their position in the column (1 column, 2 column, etc) and the ...
1
vote
2answers
88 views

Clearing arguments passed to a Module

Is there a possible way to clear the arguments passed to a module to release some memory. I believe that arguments passed to modules are passed by value rather than pass by reference. e.g. I have the ...
0
votes
2answers
135 views
5
votes
3answers
224 views

Split list of states by run lengths and discontinuous changes in state

I was asked to look into writing some simulation code for a user, where the simulation output (x) would oscillate between three possible states: ...
0
votes
0answers
72 views

How to save the results in an identical Excel file (.xls) in each iteration of a Do loop

Assume the following code (Below code is just an example to clearly illustrate my problem): ...
2
votes
0answers
48 views

What is “ (Dialog) Input [ ] := ” after evaluating a cell?

I have done a time-consuming run and calculation. After many hours ( about 7 hours!), the black color which shows that the cell is evaluating, turn into gray and a strange text appears like this : ...
0
votes
0answers
98 views

A problem with functions and Infinite expression 1/0 encountering

Following code (function) makes integrals and then replace f[x] with Cos functions and calculate the definite parametric ...
0
votes
1answer
105 views

A problem with set values

The following code is just an example to clearly explain my problem. Assume that : ...
1
vote
1answer
115 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 ...
1
vote
3answers
175 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 ...
1
vote
3answers
179 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 ...
2
votes
1answer
372 views

Calculate mean square displacements for different particles from a excel file

I have the particle movement data in the following format: ...
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: ...
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 ...
5
votes
7answers
383 views

How to find the longest matching sublists in a list

Given a list of 2D points, i.e. {p1, p2, ..., pn} the list may contain equal points, i.e. pi = pj. In this case it may also be true that a sublist of ...
2
votes
2answers
159 views

How to replace data in a list (tree) in a functional Mathematica way?

I have list containing 2D points in various groupings, i.e. points, lists of points (figures), lists of lists of points (patterns) and finally a list of patterns. The list also contains other data, ...
8
votes
4answers
270 views

Searching linked lists that contain lists?

Following the advice I've read here and other sites, I've been trying to use the Mathematica equivalent of a linked lists... ...
10
votes
5answers
485 views

How to find first list element that differs from average of N previous elements by more than a given amount?

Given a list of real numbers, I need to write a function that returns the value of the first element in the list that differs from the mean of the previous $N$ elements by greater than $P$ standard ...
16
votes
12answers
1k views

Pick elements of largest absolute value

For example, given list = {{1, -3, -5}, {2, 1, 6}, {0, 2, 4}, {-9, 2, 6}} should return: {-5, 6, 4, -9} Updated I found ...
17
votes
1answer
344 views

Underlying Algorithms for List Manipulation Functions

Does anyone know, or know of a link for the underlying algorithms used for list manipulation functions? Specifically: Union with and without the ...
5
votes
2answers
189 views

How to group lists that own one common element?

I have produced a list of sub-lists by the following: ...
4
votes
1answer
790 views

Mutual Information involving two matrix states

I basically retrieved the following technique of evaluating the mutual information involving two matrices from this site at http://bmia.bmt.tue.nl/People/BRomeny/Courses/8C080/default.htm The ...
2
votes
1answer
87 views

Map and Scan ignore HoldFirst

I am trying to write a simple function that takes a list of data and outputs it to a file. I'd like the name of the file to be the same as the variable that holds the list. It seems that giving a ...
1
vote
0answers
141 views

Why doesn't ParallelMap improve the performance of FoldList?

This question arose during my analysis of the following problem: filling gaps. (The code used here is Simon Woods's work.) FoldList seems to not cooperate with ...
12
votes
10answers
602 views

How can I generate a nested array like this one?

Well, this is how the array looks like: I came up with this code: n = 10; Nest[ArrayPad[#, 1, 1 - #[[1, 1]]] &, {{1}}, n] /. {1 -> "*"} Any better ...
5
votes
1answer
168 views

What is the fastest way to maintain a large set of expressions?

In my algorithm I need to maintain a set (an unordered list of distinct elements) of expressions supporting two operations: Test an expression for membership in the set Adding a new expression to ...
4
votes
3answers
183 views

Renaming and indexing list of rules

I have a list of rules that represents a list of parameters to be applied to a circuit model (Wolfram SystemModeler model): ...
1
vote
2answers
124 views

Counting a cardinality of a subset satisfying special property

Suppose that we have a set of 9 2-dimensional vectors $c$ by m=3; n=2; c=Tuples[Range[m],n]; We want to define a subset $S$ of vectors in $c$ by the following: ...
0
votes
0answers
39 views

Generating partitions of a set with a specified size of the parts [duplicate]

I tried the following (inspired by the answer here) myList = {a, b, c}; Needs["Combinatorica`"]; SetPartitions[myList] and I got this answer, ...
18
votes
4answers
594 views

Accessing list elements by name

First, a bit of a long introduction to my problem: I only have a few weeks of Mathematica experience. I am creating a mathematica application that calculates some material properties of steel based ...
11
votes
3answers
935 views

What is Mathematica's equivalent to MATLAB's filter function?

The MATLAB code filter(0.5,[1, -0.5], [1:10]) is equivalent to Rest@FoldList[(#1 + #2)/2. &, 0, Range[10]] I don't ...
1
vote
2answers
306 views

Select rows from table by keys

I am looking for a way to iteratively select all sublists with the same ID (my 1st column, residual columns are AbsoluteTime entries). First, I obtained the list of ...
0
votes
1answer
91 views

Collecting roots of different equations and create a list

I solve two equations and have two solutions one by each equation. I want to create list of these roots. Could anyone please help me? Appreciate it. m02R150 = FindRoot[P1 == 0, {E1, 0.07, 0.1}] ...
0
votes
1answer
116 views

Where do those nulls come from? [closed]

I have seen discussions of unwanted nulls in the output in the context of building lists with conditions on the elements, but that is not involved here. I would like to know where the nulls come from ...
8
votes
4answers
399 views

Best way to modify values in a list of rules?

Recently I had to solve a problem similar to this: Let's say I have a list of list of rules ...
9
votes
4answers
721 views

Passing large list by reference

I have the following problem: I would like to control evaluation of a variable that points to a list. For example, frequently in the code I have functions of the form that are supposed to work on ...
0
votes
1answer
497 views

Find Roots in Do loop

Task: Finding roots in loop t = List[1, 2, 3, 4, 5] fx[x_] := a*x^2 - 5 List[Do[Print[FindRoot[fx[k] == 1, {a, 1}]], {k, 0, 5}]] Output: Currently the output is ...
6
votes
3answers
318 views

Delete elements from a list really fast

I have this bit of code that works, but it's very slow when there are 600k elements in the list: ...
11
votes
8answers
451 views

Any built-in function to generate successive sublists from a list?

Given lst = {a, b, c, d} I'd like to generate {{a}, {a, b}, {a, b, c}, {a, b, c, d}} but using built-in functions only, ...
1
vote
3answers
994 views

How to create functions of arbitrary number of variables? [duplicate]

In the following code what would be the simplest way to generalize it to say some $N_f$ number of $z$ instead of just $z_1$ and $z_2$? ...
7
votes
3answers
611 views

Filtering elements from a list

Suppose that I have a list {{{2, 1}, {4, 3}, {2, 4}}, {{2, 1}, {4, 3}, {3, 1}}, {{2, 1}, {2, 4}, {3, 1}}, {{4, 3}, {2, 4}, {1, 2}}} I want to make a new list ...
2
votes
1answer
194 views

Computing closest set of points to each point in large set — running out of memory (arrays unpacking)

I have a large set of points in 3D and I'm trying to identify all the points that lie within a certain distance of each point. Then using this data store the vector between the pairs of points. I ...
4
votes
1answer
232 views

speed up iteration with conditionals plus optimize memory usage

Given list1 and list2 whose elements are vectors of a certain (fixed) dimension, I am interested in the behaviour of a scalar ...
4
votes
4answers
188 views

clean functional way to get first n rows that yield maximum rank

I have a matrix A and want the matrix consisting of the first n rows of A, having the same rank as A, where n is minimal. More generally, I want the shortest "start piece" of a list, such that some ...
4
votes
2answers
513 views

Optimize inner loops

I'm Mathematica newbie so please be gentle :) I have this, heavily non-optimized part of code, which I would like to speed up. I have put all matrices to be RandomReal, but in my code they take ...
6
votes
1answer
260 views

Why is MapIndexed better than mapping over a range?

Background I'm working on an application in which I need to create and control two sets of locators. I know from reading the Mathematica documentation and certain posts on Mathematica.SE that this ...