Questions tagged [list-manipulation]
Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.
9,315
questions
6
votes
5
answers
383
views
How can I change elements in a matrix to a combination of other elements?
Suppose I have a list like
{
{x1,y1,z1},
{x2,y2,z2},
{x3,y3,z3},
...
}
and I want to change it to
...
1
vote
0
answers
84
views
Modifying list operation [closed]
I have the following list
...
1
vote
1
answer
37
views
Pick last row of a matrix for which the second part of the row is smaller then a certain value
Lets say there is a matrix={{1,2,3},{4,5,6},{7,8,9}}. Im interested on the position of the last row, for which the second element of that row is strictly smaller ...
9
votes
6
answers
1k
views
How can I define a sequence of Integers which only contains the first k integers, then doesnt contain the next j integers, and so on
I need a list of integers to check if a variable has one of the values of the list.
If[ MemberQ[List,x], Green, Red]
The list contains integers and is characterized ...
4
votes
2
answers
160
views
How to create an Xlookup function (similair to Excel)
Edit: I have added table3, which is closer to my real life use case and timings of the code
Edit 2: I have added table4, which ...
3
votes
2
answers
181
views
Replace a column/row of a matrix under a condition by a random number
Lets say there is a matrix of the form:
matrix = {{1,2,3},{4,5,6},{7,8,9}}
I want to replace the elements of the last column, if they are larger then zero, by the ...
2
votes
1
answer
86
views
How can I change entries in a list of lists depending on the entries in the list itself?
I have an 3D dimensional Array of data. It has this kind of strucuture: {i,x,y}
...
1
vote
2
answers
91
views
Binary Distance between the two Primes
Given a prime number p, is there always a smaller positive integer exponent k such that p+2^k...
4
votes
3
answers
130
views
Arrange solutions of equations in column form in a table
If we have the following system of equations:
...
4
votes
2
answers
150
views
Extract terms containing symbols
I would like to be able to extract terms that contain a symbol expression and leave the special function alone.
I have a list:
...
4
votes
2
answers
244
views
Enumeration of a nested list
My problem is consisting of following:
I have a nested list of following form:
{{B, v ** v, b ** B}, {b, B ** b}, {b ** B, v ** v}, {}}
And I want to enumerate ...
1
vote
2
answers
53
views
How to distinguish these strings when extracting parameters?
Consider the following list:
...
1
vote
2
answers
54
views
How to extract manipulated indexed variables from Manipulate
I am struggling with getting values of variables that are manipulated with Manipulate:
The code:
...
0
votes
1
answer
84
views
Solving Transcendental Equations [closed]
I want to solve the transcendental equations as follows
$$ A=\frac{w^{\frac{b}{a}}}{c^{\frac{2}{a}}}\mid cos(\frac{b\pi}{2a})\mid $$
$$ c=\frac{c^{\frac{2}{a}}}{w^{\frac{b}{a}-1}}\mid csc(\frac{b\pi}{...
1
vote
2
answers
38
views
ListPointPlot3D {{x1,y1,z1},...} with Manipulate t. Data is {{t1,x1,y1,z1},{t2,x2,y2,z2}...}
I have a data {{t1,x1,y1,z1},{t2,x2,y2,z2}...}, and I am trying to plot 'x,y,z' in 3D with Manipulating 't'
I have tried the similar thing before, but the 'x,y,z' were a function of t. (I wrote it ...
1
vote
1
answer
55
views
Creating coefficient matrix
Suppose I have 3 elements, $\{A1,A2,A3\}$. I have 3 independent polynomials, stored in a list $\{A1-s*A2,A2,A2+A3\}$. I want to create a matrix form which will help to visualize easily which elements ...
3
votes
1
answer
145
views
Why is the code with multiple Do slower than the one without them, and why is For faster than Do?
For some table tab having N rows and n columns, I need to go over all its rows $j$ and ...
0
votes
0
answers
45
views
How to flatten a list in NMaximize?
I have the following function:
...
3
votes
1
answer
92
views
FindPeaks in a 2d list and half values
FindPeaks is a nice little help. But it only works on 1D lists and tends to return half integer values for positions of the peaks which are ultimately very useless ...
5
votes
2
answers
149
views
Numerical integration of a list
I have a list, p, obtained by a complex numerical procedure. Its element has the structure: {k,fi,z}. Below I give a simplified ...
5
votes
5
answers
330
views
Add the number of occurrences to the list elements
I'm not explaining it well, sorry.
There is a list[j] consisting of randomly selected number {a,b} elements.
For example,({j,4})
...
0
votes
0
answers
74
views
Why is the following code not compilable?
The code below should replace particular elements of some table acccolumns if some condition is satisfied:
...
0
votes
1
answer
60
views
Why does the following code not change the table?
Consider the following code:
...
7
votes
5
answers
153
views
Generating all expressions of the form $a*x + b*y + c*z$ where $a,b,c\in \{ -1,0,1\}$
Suppose I have an expressions, i.e.,
a*x + b*y + c*z
If the coefficient $a,b,c \in \{-1,0,1\}$, I want to make them as a list., i.e. ,
$\{ \{-x+y\},\{-x-y-z\}, \...
4
votes
1
answer
79
views
ListPlot color function depending on point stability
I have the following code that finds the critical points of the function enAll[v1,vTotal] and there is a plot of those points as shown below. However, I need each point on the plot to be colored ...
1
vote
2
answers
78
views
Changing part of a list of unequal arrays
I have {x, y, f(x,y)} data in multiple (n x 3) arrays with unequal length, which I read in from different files in order to later plot them using ListPlot3D. I ...
4
votes
2
answers
214
views
Efficient use of GatherBy on large list to remove duplicates
I have a large nested list of rules, wherein elements which have repeated entries on the LHS of the rules should be deleted. For instance
...
4
votes
2
answers
147
views
How to re-arrange a list of results?
The function mat[v1,vTot] has either one solution or three solution, depending on what vTot is. I want to make a table with pairs of points corresponding to the value of mat and its corresponding vTot....
6
votes
3
answers
396
views
How to combine elements of a list who have two elements in common?
I am a bit new to both Mathematica and StackExchange, so I apologize if I have made any mistakes in my question or missed an obvious answer.
I have lists of the form
...
4
votes
2
answers
119
views
Remove outermost curly brackets for table of variable dimension [duplicate]
I have $\vec k=(k_1,k_2,...,k_d)$, where $d$ is variable. I want to construct a table that iterates $a_i$ from $0$ to $k_i$, over a function of $\vec k$ and $\vec a$. Here is what I did (here $k$ will ...
1
vote
1
answer
42
views
How to obtain a list of pairs of exponents in a double series expansion?
Let's say we have a function of two variables $f(x,y)$ and we work out its Taylor expansion up to some power. I would like to use Mathematica to construct a list of all exponents that appear in the ...
2
votes
0
answers
59
views
Pick position of a particular list in the list of lists [closed]
Suppose I have some following lists with different size
...
0
votes
1
answer
272
views
Why are the results of these codes different?
I apologize for the very long question with a relatively complicated code. I am dealing with a real problem, and the question below appeared from my attempt to simplify this problem to ask about it ...
1
vote
2
answers
100
views
How to make a list be skipped if it is an empty set when it is being iterated over
Could you give me some advice?
There is a box[a,b] in which the number and number of lists are randomly generated.
For example as follows.
...
0
votes
1
answer
61
views
Code doesn't stop running - how to fix Part::partw? [closed]
I have this code divided into two notebooks, the first notebook is running just fine, and It gives some information that the second notebook uses, like some variables. The second notebook exhibits the ...
3
votes
2
answers
99
views
Create a new table by deleting some similar rows, provided that their outputs are collected
How to delete duplicate rows, collect their outputs in general, and create a new table.
The figure below shows the idea required to create the new table
The idea is that if the rows are similar in ...
4
votes
2
answers
123
views
Selecting sublists from a ragged array of lists of strings
A ragged array of strings with a mix of sublists is processed to output some sublists and not others.
The sublists to output have a date, data, and information; in no particular order.
The information ...
0
votes
1
answer
47
views
Use table data to substitute into a function
If I have the following function
Rx = Subscript[x, 1] Subscript[x, 2] + Subscript[x, 3] - Subscript[x, 1] Subscript[x, 2] Subscript[x, 3]
I want to add it as a ...
2
votes
1
answer
53
views
Collect columns in a table
How can I add the elements of certain rows and show them as a new row in the table?
The following table shows the required process:
My attempt is just to make the table
...
6
votes
3
answers
279
views
Split list into ascending sublists
I would like to split a list into non-overlapping, ascending (more precisely, non-descending with ≤) sublists. The function would be close to LongestOrderedSequence,...
4
votes
4
answers
218
views
How to regroup elements of a cluster?
Given a clustering of unique elements,
clustering = {{10, 40, 30}, {200, 500}, {6}, {7}, {8}};
How do I group a given subset of them into the same cluster?
eg:
<...
5
votes
9
answers
371
views
Rotate elements in a list using a for loop
I have the following list.
data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
I want to replace (rotate) each element using a for loop. In the first step, the first element ...
0
votes
0
answers
61
views
How can I tell Mathematica that $0^0$ is equal to 1 [duplicate]
I input: Table[Binomial[3, k] (3 - k)^(3 - k) (k + 1)^(k - 1), {k, 0, 3}].
Mathematica returns: {27, 12, 9, Indeterminate}.
I want Mathematica to return: {27, 12, 9, 16}.
1
vote
1
answer
120
views
Fixing code for a combinatorics problem
The problem I am solving is:
Determine all possible values of positive integer $n$, such that there are $n$ different $3$-element subsets $A_1,A_2,...,A_n$ of the set $\{1,2,...,n\}$, with $|A_i \cap ...
5
votes
2
answers
354
views
Efficient way for writing -1 <= X[i,j] <=1
I have an $m \times n$ variable $X$. I want to write the following constraint
...
3
votes
1
answer
89
views
Constructing Toeplitz Matrix
How can I construct this matrix?
5
votes
3
answers
202
views
How can I remove and keep the elements of this set?
I have a list
list = {{1, 3, 7, 1, 2, 1, 4, 7}, {6, 2, 7, 9, 4, 3, 6, 7}, {2, 8, 8, 2, 3, 2, 4, 6}, {5, 7, 7, 5, 2, 1, 2, 4}, {8, 10, 10, 8, 2, 1, 2, 4}}
Consider ...
2
votes
2
answers
73
views
Error with using ReplaceAll
I wrote a For Loop. In this For Loop, I want to change the values of a list. The main issue is:
I have a nested list like:
...
3
votes
4
answers
203
views
Build a region from an unsorted set of points (Imported from a .DXF file)
Please consider trying to download the following .dxf files :
DXF File - HEA
DXF File - UNP
DXF File - RRW
Context :
Every file contains a drawing of a particular type of steel profile used in civil ...
1
vote
1
answer
37
views
Evaluate integrals on imported data and export the results
I have imported an excel file Data=Import["data.xlsx"] which gives the output like this:
...