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
5 votes
2 answers
167 views

A Nothing for Associations

In the same way that Nothing disappears from Lists, is there a built-in that when it appears as the value in an association the ...
  • 5,484
-1 votes
1 answer
57 views

A general term of this sequence [closed]

My question is about the set theory. I have c[0]={{1}} and i want to define c[n] as follows: ...
2 votes
0 answers
39 views

Delete list item if message is thrown

I have a nested list with each element containing FindRoot like this: {FindRoot[a,b], FindRoot[c,d], FindRoot[e,f],...} ...
1 vote
2 answers
105 views

FindFit; not a valid variable [closed]

I am trying to fit the function in model, however I get General::ivar: 5000.` is not a valid variable. this error. My code is that and ...
  • 13
6 votes
5 answers
637 views

How to divide the second element of a list by a number

I have the following list of number: ...
  • 181
0 votes
1 answer
36 views

Mathematic doesn't compute absolute value of difference of solution of ODE from two different numerical methods

While trying to compare the solution to an ODE by 2 different numerical methods Mathematica gives a wrong result. More specifically I have te code. ...
  • 125
2 votes
1 answer
61 views

From list shown below - highlight in BOLD the pair with the highest value

I have been trying for sometime to achieve the following:- Given the list - {{"E", 3}, {"D", 2}, {"S", 2}, {"M", 2}} a list of pairs which maybe 4 pairs - more ...
2 votes
2 answers
245 views

Storing the data at the end of the For loop

I have a For loop ...
  • 123
1 vote
1 answer
133 views

Creating and exporting .dat file as desired

Please help me create a .dat file with the data format is as in the link given below https://pastebin.com/CXq0N3aT And export the file. Part of the data format in ...
  • 123
6 votes
5 answers
811 views

How can I apply a function only to even-index elements of a list?

A = {1, 2, 3, 4, 5} and, Dd[P_] := P + 1 How can I map "Dd" into "A" such that the outcome is: {1, 3, 3, 5, ...
  • 61
0 votes
1 answer
55 views

How can I outline my figures?

I am currently producing some figures, all using the same colours. This, however makes them impossible to distingis from one another. This is my code ...
4 votes
2 answers
118 views

Extracting the second largest and minimum values, and plot

How to extract the second lowest and the second largest values of each row, and plot them as upper and lower graphs? I try with TakeLargest (or ...
  • 173
0 votes
1 answer
50 views

How to compose output of NDSolve with another function? [duplicate]

If I want to solve some ODE by NDSolve but want to make a table of the solution $u(x)$ NDSolve gave me evaluated at another function, say $x(i)$, how would I do that, here's an example ...
  • 125
7 votes
5 answers
430 views

Smart way to remove rules from lists, leaving just values, specifically from FindMinimum output

I would like to know if there is a direct way to remove the rules from a list of rules. I know that, simply, this can be done with: ...
0 votes
1 answer
99 views

How to find multiple zeroes of a single function

This is the problem I am solving. I have defined my wanted equation as it is shown on the picture. Finding the first 0 (root) is not difficult with using FindRoot function. The problem that i am ...
1 vote
0 answers
78 views

How to DeleteDuplicates from a list of Rules having set to different values whereby we wish to drop the last occurrence?

About This Function This will eventually set default values for Options based on the end users preferences so that no OptionsPattern need ever be set. The symbol<...
  • 1,977
2 votes
3 answers
140 views

Insert a dynamic vector into a matrix

If I have the following dynamic vector Cs[NN_] := Table[{Sin[(2*i - 1) τ], Sin[(2*i - 1) τ]}, {i, 1, NN}] // Flatten The size of Cs depends on the integer ...
  • 1,215
7 votes
3 answers
260 views

Removed all undefined from a list of rules

My output from NSolve is a list of rules, most of these are undefined, I want to remove those rules. More specifically I have a list ...
  • 359
0 votes
1 answer
79 views

3D Plot using data from a .dat file

Suppose I have a .dat file, that I could easily manage to import it and it read as below ...
  • 664
3 votes
1 answer
79 views

ListPlot with stacked Layout: Filling Color and Line Color

I have a Listplot like this: ...
  • 679
10 votes
6 answers
222 views

Joining sublists of nested list based on sublist position

I have nested list with sublists of varying lengths like this: list={{a,b,c,d},{e,f},{g,h,i},{j},{k,l},{m,n,o}} How can I join the 4th and 5th sublists based on ...
  • 327
5 votes
4 answers
222 views

Replace list of list according to second list

Given p = {{2, 0}, {3, 0}, {4, 0}, {5, 0}, {8, 0}, {11, 0}} I want to replace parts according to a second list t1 if the first ...
  • 2,030
3 votes
5 answers
213 views

Check how far positions in list to straight line

I have a list of X and Y positions, I do not know what the length of the list. I want to create a straight line only by use the first and last position in the list. Then, I want to check how far the ...
  • 245
6 votes
7 answers
581 views

How to create a list of lists using Range[]

Given an integer, say 20, how can I create the following irregular list of lists? lst={5,7,3,5}; Range[#]&/@lst; generates this: ...
  • 4,411
11 votes
11 answers
2k views

How can I construct this matrix?

How can I construct this matrix by MMA? $\left(\begin{array}{cccccc}1 & 2 & 3 & \cdots & n-1 & n \\ n & 1 & 2 & \cdots & n-2 & n-1 \\ n-1 & n & 1 & \...
  • 1,513
0 votes
0 answers
40 views

Eliminate point of function

So I have a function f(x) and I know that for x=x1 the function goes to infinity. I want to remove this point of the function and a "new" function that interpolates from x1- to x1+ at that ...
5 votes
2 answers
200 views

How can I create a list of not-evenly spaced numbers?

I want to create an array of numbers, but i want them to be more dense according to a sine function (more density of points near $0$, $\pi$, $2\pi$ and so on. I would like something like a ...
3 votes
3 answers
187 views

how to adjust a replacement list

I have this list of replacement rules: {{2, 15} -> 1, {2, 2} -> 1, {2, 2} -> 1} What I need is ...
  • 647
3 votes
2 answers
55 views

Drop element of nested list based on position [closed]

I have a nested list, with each list differing in length and made up of strings: ...
  • 327
0 votes
0 answers
64 views

How do we define the function near the end of my post?

Suppose I have two sets $F_{1,n}$ and $F_{2,n}$ written as: ...
  • 249
3 votes
3 answers
256 views

How can I delete duplicates with Abs?

I have this list with some duplicate elements and I want to delete duplicate ones. ...
  • 2,484
3 votes
3 answers
90 views

Get coefficient of a symbolized symbol in a sum that involves other symbolized expressions

My mathematica notebook begins with symbolizing all expressions of the form $x$ subscript an integer, "$x_k$", ...
  • 165
0 votes
1 answer
102 views

How can I obtain a list of all consecutive pairs of elements in a list? [duplicate]

For example, given {a,b,c,d} I want {{a,b},{b,c},{c,d}} What's the best way to do this?
4 votes
3 answers
189 views

How to change list of rules with the new list?

everyone! I have the "big" list of rules ...
3 votes
5 answers
175 views

How can I get a list of all distinct unordered pairs of numbers in a specific range? [duplicate]

If I do e.g. Flatten[Outer[List, Range[3], Range[3]], 1] I get ...
0 votes
1 answer
105 views

Efficient algorithm for Euclidean distance on a lattice [closed]

I am unable to code the problem in Mathematica. For the problem, please see the attached image. Help in this regard will be greatly appreciated. The statement of the problem is as follows: Consider a ...
  • 21
5 votes
4 answers
164 views

Need list of unequal lengths to be paired with year

Suppose I have a list of five lists, each with a different number of elements ...
  • 649
1 vote
2 answers
67 views

Make a tabbed Workbook of Spreadsheets with TabView (and TableView) [closed]

I'd like to display a 3D table as a tabbed group of 2D tables. As a bonus incorporate TableView to enable editing. Here is my attempt:
  • 1,288
0 votes
1 answer
78 views

Visualization of an iteration scheme in Mathematica

I have a mapping T as attached (here. Now for $x_{0}\in C$ the Mann iteration process read as $x_{n+1}=(1-\alpha_{n})x_{n}+\alpha_{n}Tx_{n}$ n=0,1,2,3,... Now I want to obtain a visualization of the ...
  • 161
0 votes
1 answer
85 views

Plotting a cylinder using ListPlot3d

I have a table of dimensions {$\theta$,$z$}= {20,200} that I want to plot as a cylinder instead of a plane. The code I have is: ...
  • 73
6 votes
5 answers
509 views

Need a "rolling" list of lists

I have 32 columns of annual data in varying lengths which I can simulate as follows: ...
  • 649
0 votes
1 answer
48 views

How to plot a set-valued mapping graph

I know that if $T$ is a single-valued mapping for example $T(x)=x^{2}$ for all $x\in[0,1]$ then its graph can be plot using Plot[x^2, {x, 0, 1}] Is there any way ...
  • 161
0 votes
0 answers
73 views

Numerical values of an iterative scheme are different from values in a Paper

I want to solve a pde $y^{\prime\prime}(t)=\frac{3}{2}y(t)^{2}$ with boundary conditions $y(0)=4$ and $y(1)=1$. The exact solution of this problem is $y(t)=\frac{4}{(1+t)^{2}}$. Now I want to solve ...
  • 161
1 vote
1 answer
73 views

Plotting multidimensional tables

I have a tridiagonal matrix created by ...
  • 727
3 votes
2 answers
104 views

Solve a differential eq with a boundray condtion and plot it

I just wanted to know how to plot this for different value of a,b and f (Table[])? ...
6 votes
4 answers
403 views

Is there a more elegant solution than f[a, b, Sequence@@#3,...]?

I am trying to construct a list of many possible combinations using Outer and Permutations. Something that looks like that: <...
1 vote
0 answers
47 views

How to rescale list to interval $(0,1)$ [closed]

Imagine I have an arbitrary list l = RandomReal[{-5, 10}, 10] Out[]= {4.17452, 1.75762, 4.16905, -3.63225, 8.34172, 5.39626, -4.2107, 3.50873, -1.52441, -3.7147} ...
  • 4,388
6 votes
4 answers
191 views

Row function to join together binary number elements

I am trying to join entries of binary numbers at the lowest level of a nested list, e.g. ...
  • 65
4 votes
5 answers
253 views

How to define functions using a list of polynomials?

I feel stupid for not being able to do this and I think it is just a syntax error. Let's say i have the following list: L={x,xy,x^2+y,xyz,x^2} How do I define 5 ...
  • 635
4 votes
2 answers
86 views

Tuples which treats re-ordering as equivalent [duplicate]

I would like to define a new function myTuples, that behaves just like Tuples, except that it treats, as with ...
  • 1,249

1
3 4
5
6 7
177