Tagged Questions

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

252 views

How to imitate list comprehensions for constant arrays?

In Python, ['a'] * 10 generates ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'] and ...
61 views

Inputting values into the variables without having to input the matrix all over again

I'm practicing using LU decomposition on Mathematica. I am able to find the L & U matrices, specifically the variables. However, i find it tedious having to input the newly found values and form ...
70 views

Count participation of variable list

I have the directed edges of a graph given by a list of variable (vertex) pairs. ...
63 views

How to extract part of association?

Considering an association: asc = <|"a"->1, "b"->2, "c"-><|"e"->3, "c"->4|>, "d"->5, "e"->6, "f"-><|"g"->7|>|> How ...
241 views

List all “duplicate” elements in Tally

Tally[list,test] can use a custom function test to judge if elements are equal. But the output will only give the first element ...
121 views

How can I write a loop to get many values from a solution?

I am looking at the value of x[t] at day t = 200 over several years. I tried to do it using a For-loop but it didn't work. This ...
82 views

Find sub-sets of vanishing additions or subtractions from a list?

Let's say I have a list L containing n numerical numbers. Now I want to find all sub-sets of ...
238 views

Import a column of data, make a matrix from it and export it WITHOUT curly braces

I'm new here and with Mathematica, too. I want Mathematica to import data from a txt file (it has one column of data). These entries are z-values. From this I want to make a matrix - 508 entries make ...
158 views

Find position avoiding For loop

I have a list: {a,b,c,d,e,f} And a function sizeFunc[element_] which returns the size ...
66 views

Dropping rational coefficients

I have a list of expressions (they all are exact numeric quantities, not containing any variables), some of them have integer or rationals coefficients, or complex coefficients with rational or ...
32 views

Accessing the elements of a list of values [closed]

I have a list of polynomials (all with the variable x) called lyle and a function that accesses this list and evaluates it at ...
114 views

Replace elements in some region in a list

I want to replace some elements in list. Assume that we have A={{1,2,3,4}, {5,6,7,8}, {9,10,11,12}, {13,14,15,16}} and we want to replace elements <...
66 views

Sort and Save Matrices Eigenvectors to a Larger Matrix

We are going to sort and save all orthoginalized-eigenvectors of 4*4 random matrices (produced in any iteration) to a larger matrix such as storagematrix. Since, produced random matrices are 4*4, ...
172 views

Match a variable name pattern [duplicate]

I have a list of variables: {RBI,RCD,ASD,FGH} I want to select only those whose name starts with R. Using the pattern Rx_ ...
152 views

Join nested lists based on first and last elements within each list

I have a nested list like this: test1 = {{1, 3}, {1, 4}, {1, 7}, {2, 1}, {3, 5}, {4, 1}, {5, 2}, {6, 1}, {7, 6}} I want to join the lists together depending on ...
140 views

Identify a scalar, a list

I have a symbolic scalar m2 and a symbolic list (representing a 3x3 matrix) A. I want a function which does something like: <...
78 views

Convert a list of lists of rules to a list of values [closed]

I have a list of the following form: thisVeryExcitingList={{x->1},{x->2},{x->3}} I would like to convert it to the form ...
200 views

Move element inside a list

I need to change the position of a single element in a list. Example: I start with: {a,b,c,d,e,f} I want to move the a before ...
243 views

Improving a selection routine

How can this code for extracting the smallest (absolute) real value be improved? and would it be simpler using associations? ...
105 views

Delete Element within a List based on the Order [closed]

I want to do the following, deleting the element of a list that do not match an increasing order as example: {1,2,3,4,6,5,7,8}->{1,2,3,4,6,7,8} I've thought of using DeleteCases but I'm not able to ...
174 views

Do not expand matrices in Mathematica calculation

Here is an example of a problem I'm having. Consider that I have defined: omega={{p[t]},{q[t]},{r[t]}} x={{a},{b},{c}} R={{1,2,3},{4,5,6},{7,8,d}} What I would ...
537 views

For loop in Length computation code

Here is a code I wrote that is supposed to give the length of list after some splitting and regrouping. But it is inefficient. Is there a way to rewrite in more professional and efficient way? I guess ...
55 views

Dynamic insertion of variables

I have a list of eigenvectors of a given matrix. I need to programmatically modify this list by multiplying each vector by a variable #i, e.g. ...
60 views

Changing the precision of data in a list of matrices

I have a list of matrices ...
442 views

List manipulation challenge

It's necessary to get from list = {{a1, b1, c1}, {a2, b2, c2}, {a3, b3, c3},{a4, b4, c4}, {a5, b5, c5}}; I'd like to do this with ...
87 views

Is there a way to create a table where the number of dimensions is parameterized?

I'm imagining the likes of this: ...
40 views

Dot production associated with comparison process of different matrices eigenvectors

With thanks to Guess who in the link module using.. We created functional 5*5 matrices: ...
71 views

Module using for creating a table [closed]

I want to have a 4 tables with using of module. Unfortunately I don't know why doesn't it work ...
88 views

List of list to list of rules

I have a list of this type p = {{y, 1, 3}, {x, 2, 0}, {z, 3, 1/(k + 1)}} I can use a Do loop that is ...
293 views

Converting a Table to a Dataset

I feel like this is a simple task, and there may be a built in method to doing this (but I can't find it if there is). I would like to be able to take a table and convert it into a structured Dataset. ...
124 views

Difficulties with list manipulation

I have a list of five elements. For example, list1 = {a1, a2, a3, a4, a5}; I'm trying to get a list: ...
30 views

Specifying plot markers (filled diamonds or squares) [duplicate]

I can plot my list data and I can use of specifying circle to show my plot-markers. I used of Mr.Wizard comments on that page. But I don't know how can I fill the circles of those plot-markers with ...
106 views

Applying a function to a list with fixed intervals and fill the resulting list [closed]

I want to apply a function f to a list with fixed intervals, and then fill the gaps of the resulting list, as shown in the following picture. Since it will be run ...
61 views

Adding another looping element with a list

I have code that is looping on to elements and is working shown below ...
618 views

Use a part specification as the argument to a compiled function

I have some code that needs to generate a large matrix based on some complicated combinations of smaller matrix elements. I find that if I write a function for the element of the larger matrix, and ...
69 views

How to solve an equation given certain parameters?

I am new to Mathematica so please bear with me. I have an equation that has around 7 parameters and one unknown. I was able to use FindRoot to solve it; however, I ...
365 views

how to concatenate a list of a list of strings

I have two lists of lists, La and Lb that I want to concatenate so that every element of a list n in La is concatenated with the corresponding element of list n in Lb. For example: La = {{P, O, O, O}...
147 views

Why is there a difference when formulating patterns for Select and FirstPosition?

Select[{1, 2, 4, 7, 6, 2}, # > 2 &] Gives {4, 7, 6}. OK! So one should think that the following would work: ...
42 views

Basic Question: Split Nested list into respective elements [closed]

New to Mathematica, just have a very basic question to ask. I have a table of results like so: ...
166 views

Given a list of triangle vertices, how to find the neighbors for each vertex?

A triangle is represented by {a,b,c}, indicting that its vertex IDs are a, b, and ...
167 views

Select using MemberQ

I want to make a selection on this list ...
81 views

I have an Excel spreadsheet column with hundreds of company names on it. I need to find the address (or just city if that's easier) The operation for this is simple in wolfram alpha. i.e. typing "...
751 views

How to smooth the noise

This is a sample data ...
34 views

Creating a custom list [closed]

This is the first list lts1 = Table[i, {i, -1.8, 5.8, 0.1}] 1st question: In the interval between -1.8 and 5,8 how can I choose the step beforehand so as the ...
72 views

An extra { when importing a file [closed]

I am trying to import data from a file. {k0,{a0,b0,c0},{e0,f0,g0}} {k1,{a1,b1,c1},{e1,f1,g1}} MyList = Import[file, "Data"]; But I get a list with an extra "{" ...
548 views

Find all the possible ways of partitioning a list into a set of pairs of element

I have a list {x1,...,xN} where N is even, and I need to find all the possible ways to split it into pairs of elements, e.g. the ...
130 views

How to select a submatrix containing similar elements from a matrix? [closed]

( This question is related but does not ( fully ) answer my questions. - Finding the position of similar elements in a matrix ) I have not written code yet, I am in the design phase of code for the ...
84 views

Output matrix with common elements

Given lists of lists like a and b, I want to obtain an output like c. a = {{2, 1, 0}, {1, 2, 1}}; b = {{2, 2, 0}, { 2, 2, 1}}; c = {{2, 0, 0}, {0, 2, 1}} If ...