Questions tagged [list-manipulation]

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
61 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 ...
Tanmoy Pati's user avatar
3 votes
1 answer
149 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 ...
John Taylor's user avatar
  • 4,642
0 votes
0 answers
45 views

How to flatten a list in NMaximize?

I have the following function: ...
CMar's user avatar
  • 1
3 votes
1 answer
118 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 ...
atapaka's user avatar
  • 3,733
5 votes
2 answers
154 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 ...
Alexei Boulbitch's user avatar
7 votes
7 answers
401 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}) ...
hare's user avatar
  • 294
0 votes
0 answers
101 views

Why is the following code not compilable?

The code below should replace particular elements of some table acccolumns if some condition is satisfied: ...
John Taylor's user avatar
  • 4,642
0 votes
1 answer
60 views

Why does the following code not change the table?

Consider the following code: ...
John Taylor's user avatar
  • 4,642
7 votes
5 answers
158 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\}, \...
phy_math's user avatar
  • 801
4 votes
1 answer
81 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 ...
juv95's user avatar
  • 197
1 vote
2 answers
80 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 ...
Jani's user avatar
  • 13
4 votes
2 answers
215 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 ...
lackofgravitas's user avatar
4 votes
2 answers
152 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....
juv95's user avatar
  • 197
6 votes
3 answers
419 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 ...
Jakwins's user avatar
  • 63
4 votes
2 answers
129 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 ...
David Raveh's user avatar
1 vote
1 answer
48 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 ...
user1620696's user avatar
2 votes
0 answers
62 views

Pick position of a particular list in the list of lists [closed]

Suppose I have some following lists with different size ...
phy_math's user avatar
  • 801
0 votes
1 answer
273 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 ...
John Taylor's user avatar
  • 4,642
1 vote
2 answers
102 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. ...
hare's user avatar
  • 294
0 votes
1 answer
64 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 ...
Laura Martins's user avatar
3 votes
2 answers
102 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 ...
Emad kareem's user avatar
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 ...
ChuckD's user avatar
  • 51
0 votes
1 answer
50 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 ...
Emad kareem's user avatar
2 votes
1 answer
54 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 ...
Emad kareem's user avatar
6 votes
3 answers
287 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,...
SnzFor16Min's user avatar
  • 2,180
4 votes
4 answers
221 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: <...
IntroductionToProbability's user avatar
5 votes
9 answers
386 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 ...
Michiel van Mens's user avatar
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}.
geoffrey's user avatar
  • 795
1 vote
1 answer
123 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 ...
matrix42's user avatar
  • 6,754
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 ...
Morcus's user avatar
  • 247
3 votes
1 answer
90 views

Constructing Toeplitz Matrix

How can I construct this matrix?
V Bert's user avatar
  • 53
5 votes
3 answers
204 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 ...
John Paul Peter's user avatar
2 votes
2 answers
74 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: ...
Michiel van Mens's user avatar
3 votes
4 answers
210 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 ...
Jocelyn Minini's user avatar
1 vote
1 answer
39 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: ...
Math_student's user avatar
4 votes
3 answers
211 views

Find shortest subsequence

We will deal with arrays of chars, but not strings! Let we have the next three arrays: ...
lesobrod's user avatar
  • 1,197
8 votes
3 answers
473 views

How to set to 0 all terms in a matrix which contain a minus

For a matrix like F = {{β , x β}, {-2 β, -3 β}}; F // MatrixForm I would like to set to 0 all terms which contain a minus, in this case the bottom row, getting <...
florin's user avatar
  • 1,592
2 votes
3 answers
305 views

How to plot properly the following data?

Consider the following test data: ...
John Taylor's user avatar
  • 4,642
1 vote
2 answers
125 views

How could the whole series of graphics be saved?

I would like to save a series of graphics of a function as pictures. But the problem is that I can't manipulate the name of the graphs, because of that only the last graphics in the series is saved. ...
Mam Mam's user avatar
  • 1,753
4 votes
2 answers
88 views

PositionIndex of isomorphic value

The following example is a simplified version of a problem I am working on: equivalent[x_, y_] := Mod[x, 7] == Mod[y, 7] Given a list, say {3, 7, 5} and an integer ...
Michel's user avatar
  • 1,596
9 votes
4 answers
2k views

Find Roman numerals up to 100 that do not contain “I"

The question is from Elementary Introduction to the Wolfram Language, section 28 Tests and Conditionals: Find Roman numerals up to 100 that do not contain “I”. What am I doing wrong that the following ...
QC123_367's user avatar
  • 481
1 vote
1 answer
127 views

How to get DFT from Sound/Audio/Image?

When I'm trying to do Discrete Fourier Transform or just get a ListPlot of values from Sound object, I get error message.. I understand that Fourier command (and ListPlot of course) works only with ...
shamil khal's user avatar
1 vote
1 answer
105 views

How to sort eigenvalues (from minimum to maximum) and their corresponding eigenvectors?

When using NDEigensystem, the first eigenvalue corresponds to the first eigenvector, the second eigenvalue to the second eigenvectors, and so on. I would like to sort the eigenvalues from min to max, ...
Mam Mam's user avatar
  • 1,753
0 votes
2 answers
92 views

Multiplying a certain column from a table with a function

I have the following list of matrices whose second entry I would like to multiply/divide with a function, say f, and store the resulting table as a new table. How should I go about doing that? Thanks *...
Zihad's user avatar
  • 31
1 vote
0 answers
75 views

Separate the elements of a row [closed]

I have a $\psi$: {a,b,c,d,e,...} for example for 10 letters. How can I change it in the format: {{a},{b},{c},{d},{e},...} I ...
Inzo Babaria's user avatar
  • 1,503
1 vote
1 answer
149 views

How to combine Flatten and Partition? [closed]

In order to get list x4 from list x1, I used three operations. How to get list x4 in one ...
Mam Mam's user avatar
  • 1,753
1 vote
3 answers
99 views

List manipulation and plotting

I have a code which takes as input RandomSample[Range[d^2],4] for a given d and outputs a value ...
Dotman's user avatar
  • 414
3 votes
3 answers
241 views

How to join two one dimension lists as columns in a matrix [duplicate]

I would like to take a one dimensional list, e.g., list1={1,2,3} and add a second column, e.g., list2={a,b,c} to get ...
Rob's user avatar
  • 131
3 votes
2 answers
148 views

Plotting two variables from multiple lists

Given a few lists as below ...
User1729173's user avatar
2 votes
1 answer
62 views

comparing lists of unequal lenghts

Suppose I have three (nested) lists A , B and Cmat where ...
geom's user avatar
  • 648

1
3 4
5
6 7
188