Questions tagged [list-manipulation]
Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.
8,746
questions
2
votes
4
answers
144
views
From original dataset, find the probability of each element in each row having the maximum value in its row
Suppose I have this dataset
{{1, 3, 5}, {4, 4, 2}, {5, 3, 5}, {10, 4, 10}} // MatrixForm
How do I find the probability that each cell is the maximum in its row.
So ...
1
vote
1
answer
38
views
ListLinePlot showing the wrong domain and not starting at zero
I am trying to plot a graph that starts at zero from a list using ListLinePlot.
The code:
...
-6
votes
1
answer
70
views
Assign value to tuples from tuples [closed]
Here is my code
Can you help tell me what is wrong with my code? I am trying to assign value from a tuple of number to a tuple of variables. In my code d is the tuple of numbers and e is a tuple of ...
1
vote
1
answer
174
views
How can we fix an incorrect form of data?
incorrdata=Import["https://www.dropbox.com/s/lk7wiutjf4bx5yk/DataX.dat?dl=1"];
How can I fix this data, it should be in the form {$a,\bf{b}$} where b is ...
0
votes
1
answer
95
views
Plot eigenvalues of a matrix with two variables [closed]
I am trying to plot eigenvalues E(kx,ky) of the matrix [mat] depends on two variables kx and ky and of course n its dimension , and the matrix elements a, b and c depend on cos(kx) ; cos (ky) and cos(...
4
votes
1
answer
68
views
Ordered list of integer vectors
For a given length $n$ and a maximum positive integer value $N$, I'd like to generate a list that contains all $n$-vectors with entries between $-N$ and $N$ (of which there are $(2N+1)^n$. Further, ...
0
votes
1
answer
68
views
Splitting a data set into multiple parts
The Problem
I am trying to split a data set into multiple parts - thanks to help in the past, this has been done before into 2 parts, but I would like to extend this functionality into multiple parts (...
3
votes
2
answers
88
views
Partition the list by group of Arithmetic Progression
I have a list= {4, 8, 10, 11, 12, 14, 16, 7, 9}
How can i partition the list by group of Arithmetic Progression with common difference 1 :
{{4}, {8}, { 10, 11, 12}, {14}, {16}, {7}, {9}}
6
votes
3
answers
243
views
Replace items of list except items that are member of another list
I want to replace all items in li1 that are not members of li2 with x.
...
2
votes
3
answers
88
views
How to extract from a list based on a partial alphanumeric string
Consider the following list. I've tried various ways to extract only those pairs in the list where both elements have the string N36. Given the below, the output would be just {N36012,N36321} and {...
1
vote
0
answers
31
views
Generating a table of lists following the set of rules
I am trying to generate a table of degree sequences for simple connected graphs for a given number of nodes.
Example output for $n=4$:
...
0
votes
0
answers
42
views
Remove rows of table based upon Indeterminate value in final column
I have a large table in form
exampletable = {{1, 2, 3, 4, 6 }, {2, 3, 7, 8, Indeterminate }, {9, 2, 6, 4, Indeterminate }, {1, 7, 3, 4, 4 }}
How to Remove rows ...
0
votes
1
answer
61
views
List structure for plotting multiple y-values (with gaps on certain dates) using DateListPlot
I would like to set up a list like this
data = {{Date1,y1,y2,y3,y4,y5,y6},{Date2,y1,y2,y3,y4,y5,y6},...}
and then use DateListPlot to create various plots, e.g. y1 ...
7
votes
1
answer
158
views
Remove elements with even instances from a list
Suppose I have a list,
...
0
votes
0
answers
55
views
How can an algorithm be written in Mathematica language in a scientific paper? [duplicate]
I have a scientific research in which I used an algorithm in an optimized language to simplify the calculations, which is important and should be included in the paper.
Algorithm
...
3
votes
2
answers
91
views
how to extract members of a List sitting inside 2 by 2 table? [closed]
I have a two-by-two table. Each element of the table is a four-member list:
...
0
votes
0
answers
38
views
How to apply the map function to NMaximize to build a 2*2 table?
I have a single variable function, named globalprofitfuntion[beta]. I am using NMaximize to locate its maximizer, beta*. This function has four parameters: cv,cr,k and w. To perform sensitivity ...
1
vote
1
answer
122
views
How to get one-bit changed permutations?
The following
Tuples[{0, 1}, 2] // Permutations
produces a list of permutations of {{0, 0}, {0, 1}, {1, 0}, {1, 1}}.
If I want ...
2
votes
2
answers
108
views
Invert undirected graph edge
Suppose I have a list of edges,
{1 \[UndirectedEdge] 2, 1 \[UndirectedEdge] 3}
How do I get the 'invert' of the list,
...
3
votes
3
answers
270
views
How to get all possible sums or possiblity of sum three numbers?
Got motivation from this and I'm trying to do this:
{#1 , #2 , #3, #1 + #2 + #3}
Where #1, #2, #3 are integer numbers from 1 to ...
3
votes
2
answers
72
views
Importing multiple files with filename conditions
I have multiple pictures I would like to import all at once. The filenames range from "000001.tif" to "000200.tif." I am having a hard time importing multiple images after looking ...
4
votes
2
answers
71
views
Normalizing the output of Apart
My question is closely related to this one but the accepted answer does not meet my needs.
I have a rational function $f(x)$ in one variable which admits a partial fraction decomposition of the form
$$...
1
vote
1
answer
38
views
Manipulating the list with variables
I am trying to find the maximum element of the list for a given value of variable $c$.
The example of the list is as follows:
...
6
votes
1
answer
92
views
filling between two listplot with unequal length
I have two sets of data :
...
2
votes
3
answers
142
views
Is there a way of column-based ArrayReshape
I have checked the official document of ArrayShape of Wolfram Language. I am wondering is there a column-based way to do ArrayReshape?
Let me give a simple example,
if I run
...
0
votes
0
answers
50
views
Rearrange a Nx2 list into a 2 arrays of length N
Mathematica newbie here, thanks for your patience. I have a list of 2-element lists, i.e.
{{x1,y1}, {x2,y2}, ... {xn,yn}}
But I want to rearrange them so that ...
2
votes
1
answer
87
views
Reconstruction on large sparse array
I'm struggling with a reconstruction of a large sparse array. What I'm trying to do is to rearrange a 2 dimensional array (respresenting a system matrix for a given system of equations) such that I ...
4
votes
1
answer
78
views
How to generate a list of lists from a given list following a rule recursively?
Assume that I have made the following rule:
Rule:
{x1,x2,x3,x4,x5,x6,x7,x8}
-> {x1,x2,x3,x4,x5,x6,x7,x8}, {x4,x5,x6,x1,x2,x3,x7,x8}, {-x1,-x2,-x3,-x4,-x5,-x6,x7,x8}, {x1,-x2,x3,x4,-x5,x6,-x7,-x8}...
1
vote
1
answer
66
views
Extracting powers of a sum
Given a sum in the form
Sum[n^k, {k, kl}]
for some natural n and natural list kl, is it ...
2
votes
3
answers
230
views
How to do column vector concatenation
Is it a way to do column vector concatenation?
u = {{1},{-1},{0}};
v = {{0},{1},{-1}};
w = {{-1},{0},{1}};
I would like a matrix of {u,v,w}
3
votes
1
answer
43
views
Plotting Individual Variables from RandomFunction
I have defined an Ito Process such that:
...
2
votes
1
answer
75
views
Table range as disconnected interval
I wish to evaluate table entries but with the dummy variable taking values in separate intervals. For instance, instead of writing
...
1
vote
1
answer
59
views
Efficiency on array iteration
Consider a 2-d array n by n of the form
array1 ={ {x11,x12,x13,...,x1n},{x21,x22,x23,...,x2n},{xn1,xn2,xn3,...,xnn}}.
I want to expand every point in this array in ...
2
votes
1
answer
83
views
Minimize Sum of Hamming Distances
Problem:
Given an $n \times m$ matrix with binary values $(0,1)$, find a binary vector that minimizes the sum of Hamming Distances to the rows.
Example:
If the matrix is {{$1,1,1$},{$0,0,0$},{$1,0,1$}}...
3
votes
2
answers
89
views
Finding the consecutive distance of n-dimensional points with Mathematica
I want to create a list of (n-dimension, average of points) with 10,000 points per n-dimension.
I can't figure out how to take the distance of consecutive points. Say in 2-dimensions, there are 3 ...
1
vote
2
answers
105
views
How to generate a numerical table?
I have the following issue for generating a table in Mathematica.
How to generate a table with the limits 10^-18 to 10^-6 with steps of (1,2,3, ....10)*10^-1? e.g. It should look of the following form:...
3
votes
2
answers
110
views
Get the coordinates from RegionPlot3D
I have a plot generated with RegionPlot3D and need to extract the coordinates of the points on the plot. I'm trying to apply the approach from this question about RegionPlot to RegionPlot3D but it ...
0
votes
0
answers
48
views
Droping a row from a matrix [duplicate]
I want to drop a row from a matrix but the output seems to be:
MatrixForm[]
My code:
...
6
votes
4
answers
819
views
Implementation of MATLAB's "numgrid" function [closed]
I am looking for an implementation of MATLAB's numgrid function, in particular the "B" mode.
For example, I want to get the matrix corresponding to the ...
2
votes
1
answer
62
views
Sorting of a list of lists - i.e. list of matrices - what is the order of the sort determined by?
In the documentation we have:
Sort[list] sorts the elements of list into canonical order.
Maybe I am missing something but what does "canonical order" mean for sorting a list of matrices?
...
5
votes
3
answers
161
views
How to map a function across multiple ragged lists
Preliminaries
I have lists that are lists of lists (i.e., each list contains one or more sublists and are ragged (i.e., each sublist can have a different length, though all have a length of 1 or ...
5
votes
3
answers
204
views
matrix Crop (remove leading and trailing zeroes in matrix)
I have some matrices that have 0's around them, for example, give such a matrix
MatrixForm[ mat = ArrayPad[{{1, 2, 3}, {0, 0, 0}, {7, 8, 0}}, {{1, 2}, {2, 3}}]]
\...
1
vote
2
answers
86
views
How to assign table parameters to use it many times
I'm using two nested Table to generate data which depend on two parameters, let's say it is temperature and pressure, many times in my code. When I change the temp ...
3
votes
1
answer
162
views
Generating a non-convex polyhedron from polygons and normals
I am working on developing "directional offset" module, which requires pretty tricky mesh generation: offset values vary in different directions.
Suppose I have list of points and polygons, ...
1
vote
1
answer
60
views
Draw the values of two variables each on a axis in a square
I plot lists of {xA1} over time and lists of {yB1} over time. Now, How can I draw two lists {xA1} and {yB1} so that the values of each are shown on a separate axis inside a square? (same as below ...
0
votes
1
answer
60
views
Pulling Results from NDSolve within a Table
I am still learning the intricacies of Mathematica. I have an NDSolve within which I am trying to vary a specific parameter (I understand that ParameticNDSolve is likely a more efficient tool--the ...
0
votes
0
answers
29
views
DiscretePlot with a List as argument [duplicate]
Suppose I have some multidimensional function that is computationally very expensive to evaluate. Here, I will just use
...
0
votes
2
answers
38
views
How to replace the 6th column with another column? [duplicate]
Consider the following table:
tabb = Table[RandomReal[{0, 100}, 100], {i, 1, 10, 1}];
How to replace its kth column (say, the 52th column) by the column
...
2
votes
2
answers
138
views
Add quotes to each element in a list
How to add quotes to each element in a list?
For example, we have a list as:
...
1
vote
0
answers
56
views
An error in the short form of a two-dimensional array?
I noticed very strange behavior in the function Short when applied to a two-dimensional list of real numbers in Mathematica 12.3. Consider that
...