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
4 votes
3 answers
208 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,085
8 votes
3 answers
471 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,582
2 votes
3 answers
305 views

How to plot properly the following data?

Consider the following test data: ...
John Taylor's user avatar
  • 4,984
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,731
4 votes
2 answers
86 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 ...
Aislin_367's user avatar
1 vote
1 answer
117 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
99 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,731
0 votes
2 answers
90 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
74 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,493
1 vote
1 answer
148 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,731
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
  • 376
3 votes
3 answers
220 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
133 views

Plotting two variables from multiple lists

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

comparing lists of unequal lenghts

Suppose I have three (nested) lists A , B and Cmat where ...
geom's user avatar
  • 649
1 vote
2 answers
75 views

How do I find the "edge" values/positions in a list?

I have a list of values and am interested in finding the contiguous region above a certain threshold. I have gotten this far,but cannot seem to find the correct way to find the edges. Note: It is not ...
Indiana's user avatar
  • 321
1 vote
1 answer
64 views

How to define the boundary of the 2D region outside of the list of sub-regions?

Consider the following file. It includes a list of tables defining some regions. ...
John Taylor's user avatar
  • 4,984
1 vote
1 answer
152 views

How to merge the lines in the following way?

Consider the following curves: ...
John Taylor's user avatar
  • 4,984
4 votes
2 answers
185 views

Finding the sum of eigenvalues of a matrix depending on the parameters

There is a system that has the following Hamiltonian: $H=-\frac{1}{2}\Delta-\frac{1}{r}+\frac{B^2}{8}\rho^2-\frac{B}{2} (m + 2 m_s)$, where $r=(\rho,z,\phi), B=5, m=0, m_s=-1/2$. To find the ...
Mam Mam's user avatar
  • 1,731
5 votes
5 answers
329 views

Evaluate a function with two lists and table

I have the following function: f[x_,y_]:=x^2/y and two sample lists (that are actually longer): x={2,4,6} y={3,5,7} I want to ...
Jhoan Perez's user avatar
1 vote
2 answers
97 views

Generate family of linear inequalities from vector variable for use in `FindInstance`

Suppose that I have a vector variable xvec = Array[x, 10]. How do I generate the family of linear inequalities $$F = \{ {x\in\mathbb{R}^{10}:x_1\geq x_2,\ldots,x_9\...
rrrrr's user avatar
  • 125
0 votes
1 answer
25 views

sum elements (variables) of a vector variable [closed]

I would like to sum elements of a vector variable, e.g., Is xvec = Array[x, 10] s24 = Sum[xvec[i], {i, 2, 4}] where $s_{24}:=\sum_{i=2}^4 x_i$. However, I am ...
rrrrr's user avatar
  • 125
1 vote
1 answer
73 views

How to group the table in the following way?

Consider the following table: ...
John Taylor's user avatar
  • 4,984
0 votes
1 answer
107 views

How to split the table with different number of columns into those with equal number of columns? [closed]

Consider the following table: tab = Join[RandomReal[{0, 1}, {2, 2}], RandomReal[{0, 1}, {3, 4}], RandomReal[{0, 1}, {2, 3}]] Could you please tell me how to ...
John Taylor's user avatar
  • 4,984
4 votes
4 answers
272 views

On plotting multiple lists

I have four lists as given below: ...
User101's user avatar
  • 593
2 votes
2 answers
287 views

Is there a Mathematica function that puts a list of numbers in a normalized [1, 10[ scale

I have the following list: ...
Granger Obliviate's user avatar
2 votes
3 answers
166 views

How to write a function in the following form f[a_, b_, c_,...] so that it is flexible with respect to the number of arguments?

@lericr have written under several of my questions that the way I try to modernize the code could be made much simpler. Below is the original part of the code. The remaining parts have similar designs,...
Mam Mam's user avatar
  • 1,731
7 votes
11 answers
454 views

How can I change the data arrangement in a list?

I have data that, when imported to my notebook, is shown in the form: list = {{1,2,3},{4,5,6},{7,8,9},{10,11,12}} I want to transform this into: ...
Pedro Croti's user avatar
2 votes
1 answer
85 views

How to correctly reassign variables {c11 -> p11, c12 -> p12} using a Table or some other similar structure?

Why is the value of the function Pxx[1,2] is a number but the function Pxxx[1,2] is an expression? Isn't this construction ...
Mam Mam's user avatar
  • 1,731
2 votes
2 answers
81 views

How to use sequence of variables (Sequence) correctly?

Why does the function EER[1,2] have a different value than the function EERR[1,2]? Isn't the entry ...
Mam Mam's user avatar
  • 1,731
2 votes
2 answers
75 views

The correct notation of a function that contains an expression with NIntegrate

I tried to set the function Px[a1_, b1_, qa_, qb_]. Why does Px[1.22, 0.44, 1.40, 1.81] not give out a specific number? ...
Mam Mam's user avatar
  • 1,731
2 votes
1 answer
41 views

Table with an angle | rotate the co-ordintae

I have the following, Flatten[MapAt[Reverse, 2]@ Table[{i, j}, {i, 0, 10, 10}, {j, 0, 90, 90}], 1] that gives, ...
a019's user avatar
  • 811
9 votes
7 answers
759 views

How to quickly make a rectangular array of continous 1 and 0 given the start position of 1

I would like to make a rectangular array of 1 and 0 with continuous columns of 1. We are ...
IntroductionToProbability's user avatar
9 votes
4 answers
602 views

Check if a string is a date

I have a list of strings, {"BD4675365", "Corp", "Managers", "Syndicate", "2021-03-08", "8434926"} and I ...
apg's user avatar
  • 1,937
0 votes
1 answer
35 views

saving output and ListPlot the output:

Let's say I have x = 1; y = 2; d = x^2 + y^5 ; and x = 5; y = 3; d = x^2 + y^5 ; and ...
a019's user avatar
  • 811
1 vote
0 answers
60 views

get the first from a list using slots [closed]

Problem. I work with a list and want to get the first element. For specific reasons I want to use # in combination with Map For example ...
Michiel van Mens's user avatar
2 votes
1 answer
49 views

How to select only particular values from the list using dialog windows?

Consider some list: list = {"A","B","C","D"} How to select only particular values from it using a dynamic dialog window ...
John Taylor's user avatar
  • 4,984
0 votes
1 answer
67 views

3D plot not working, find max/min points [closed]

Im trying to plot this graph in mathematica: (x+y)sin(x-y) And this is my in- and output: Plot3D[(x + y) (Sin[x - y]), {x, -50, 50}, {y, -50, 50}] The output is ...
Kei Len's user avatar
  • 27
2 votes
2 answers
86 views

Select and deselect many options at once in CheckboxBar

Is there any way to select and deselect many parameters in Manipulate's CheckboxBar? For instance, consider following code: ...
Lechuu's user avatar
  • 392
0 votes
1 answer
76 views

Speed up compoundReturn across an array

I am trying to calculate a moving-window of compounded returns on a large 2D-array. (ie some kind of MovingMap on geometric returns) The Rows are time-steps and the Columns are different financial ...
IntroductionToProbability's user avatar
6 votes
4 answers
322 views

Delete special part from a list using Mathematica

I have a list like this: {{-0.0019,1},{-0.0018,2},...,{0,11},{0.001,6},...} I need to make a new list that start from zero value. like this: ...
caren's user avatar
  • 115
4 votes
3 answers
402 views

A loop in which three indices are changed

How could this piece of code be written in the Table, or as simply as possible? ...
Mam Mam's user avatar
  • 1,731
1 vote
2 answers
84 views

Automate data entry into the Print

There are a several variables a11, a12, a13,...,a21, <...
Mam Mam's user avatar
  • 1,731
1 vote
2 answers
147 views

Associating a string variable with a numeric variable

There is a translation operation from a numeric variable to a string variable: a[i_, j_] := Symbol["a" <> ToString[i] <> ToString[j]] How ...
Mam Mam's user avatar
  • 1,731
1 vote
1 answer
163 views

Generating a table of squares and square roots up to 100

I want to generate a table of roots and perfect squares similar to the image, but I can't find the right code, I have searched the forum for something that works for me without favorable results. Can ...
zeros's user avatar
  • 2,247
0 votes
2 answers
120 views

How to correctly specify variables in a function? [duplicate]

There is an expression ...
Mam Mam's user avatar
  • 1,731
2 votes
2 answers
88 views

Map, applying list in a defined function

Suppose I have defined some function (This is arbitrary) F[alpha_,a_,b_,c_]:=List[alpha,a+b+c] I want to apply this F for a given huge list of sets ...
phy_math's user avatar
  • 801
1 vote
1 answer
75 views

Assigning each string variable to the corresponding element from the list inside a loop

I would like to assign values from a list l to variables g1, g2, ...
Mam Mam's user avatar
  • 1,731
3 votes
4 answers
213 views

How to declare all list items are function variables?

There is a list xy = List[x, y] and an expression f = x^2 + y^2. I would like to get a function ...
Mam Mam's user avatar
  • 1,731
2 votes
1 answer
129 views

Renaming a large number of elements

I have a lot of elements of this kind: a[1], a[2], a[3], ... I would like to rename each of ...
Mam Mam's user avatar
  • 1,731