# Questions tagged [array]

Questions about Mathematica arrays, or implementing array data-type functionality, i.e, collections of regular dimensions containing elements that can be accessed by standard (computable) indices.

313 questions
Filter by
Sorted by
Tagged with
34 views

### How to discritize a function domain (break xy-plane to a grid/mesh of squares with vertex values for evaluation)? [closed]

I wrote a code using MATLAB to discritize a function's 2D domain into squares/rectangles, whose vertex data (x,y) I can use to evaluate the function at. Then I sum these values over all vertices to ...
581 views

### Avoiding zeros in ArrayReshape

Consider the list list={1,2,3,4,5,6,7,8} and imagine I wanted to change it to {{1,2,3},{4,5,6},{7,8}}. How can I do this? Using ...
35 views

### Multiple Plot + array function [closed]

please I have two problems in my script in Mathematica. I have the following code (the part of it is): ...
493 views

### Find elements of array with largest absolute value

I am wondering how to do in Mathematica the following: Given as an input a large array, I want to output a list of top $n$ entries with largest absolute value + their location within the array. ...
239 views

### How to join many tables side by side?

I have function for table $t$ t[n_] := Table[i*n, {i, 1, 3}]; For example t=(1, 2, 3), t=(2, 4, 6), and t=(3, 6, 9) To join $n=3$ tables side by side ...
95 views

### Statistics in an array [closed]

I have the following data: data = {{0.73, 0.75}, {0.70, 0.67}, {0.76}, {0.84}}; where the elements of data (data[[i]]) vary in length. I need to make statistics ...
151 views

### Build a matrix from the coordinates of its elements and complete it with zeros

Suppose that I have a data set data (input): ...
28 views

### How to monitor the progress of building a ParallelArray?

I managed to get the below code working for Array as I wish to track array building for 2d arrays. The code inside the array elements is reasonably expensive, so ...
405 views

### When nothing is defined, what does Mathematica take for #1?

I'm learning Mathematica and watched a tutorial containing this line: Array[#1 + 2 #2 &, {4, 4}] which returns this: {{3, 5, 7, 9}, {4, 6, 8, 10}, {5, 7, 9, 11}, {6, 8, 10, 12}} What does ...
53 views

### How to generate a list with elements f[i] for a function of several variables f?

I would like to create an array of length n with each element i equal to the function ...
66 views

### How to flatten a tensor product

Say I have a tensor product of four two dimensional spaces $\Lambda = S\otimes S\otimes S\otimes S$. The basis of $S$ is CB={{1,0},{0,1}} . I generate the ...
36 views

67 views

### Triangular matrices with conditions

I would like to generate a lower triangular matrix that has checkmarks in the non-zero entries. The way that I created this matrix is the following ...
67 views

### Assign Values from Array to Array [duplicate]

I am trying to simply do the following cVec = {a,b,c,d} From another expression, I obtain another vector, say, ...
22 views

### Create symmetric array of function values

I have function B[i,j] where i,j are integers. Then I create array: b = Array[B, {3,3}] now I set values of ...
214 views

### Generate an array with custom index

Apologies if this is a duplicate. I am trying (but failing) to generate the following n x n matrix in Mathematica: where G[tj, t0] is a function along the main diagonal and G[tj, tj] is a function ...
46 views

### How to evaluate an expression [closed]

I have a 3-dimensional array of numbers say A. I want to evaluate the following expression. $\displaystyle\sum_{\sigma,\tau \in S_6}(\Pi_{i=1}^6A(i,\sigma(i),\tau(i)))$. $S_6$ is the symmetric group ...
24 views

### Filling Regions (Blocks) of a Binary Matrix with Different Probabilities

This is an extension of the following question: How to generate binary array whose elements with values 1 are randomly drawn, where the most elegant answer was posted in the comments: ...
50 views

### How can I convert a matrix of 3d experimental data into a 3d list which can be interpolated in a f(x,y) function

I have a 3d experimental *.txt data with the form: y1 y2 y3 x1 f(x1,y1) f(x1,y2) f(x1,y3) x2 f(x2,y1) f(x2,y2) f(x2,y3) x3 f(x3,y1) f(x3,y2) f(x3,y3) I need to ...
76 views

### How to create an array of function values omitting certain values

I'm using Array to create function lists, f,f,f,...,f[A] where the values from $1$ through $A$ have unit increment. ...
49 views

### How to remove curly brackets in a two dimensional array near the edges?

Suppose I have a matrix {{1,2,3},{4,5,6}}. I want to remove the curly brackets near the edges, i.e., I want an output as '{1,2,3},{4,5,6}'. Somebody please help me to solve it.
34 views

### Array[] for lists with vector-like functions

I would like to use Array[] or a similar function that gives out a list of vector-like functions evaluated at different numbers. For a scalar function f this is perfectly doable with Array[]: ...
102 views

### Map vs. Table for index-specific operations on 2D arrays–Part II

This is an extension of my recent question, Map vs. Table for index-specific operations on 2D arrays For that question I gave a minimal working example, since I was more interested in learning ...
28 views

### Creating a tensor of rank $k$ from elements of a list

Given a list containing $4^k$ elements, how do I create a "square" $\underbrace{4\times...\times4}_{k\text{-times}}$ tensor of rank $k$? Intuitively, I would opt for the ...
78 views

### Function of an array with argument

Suppose c[i,t] is an array such as c[1,2]={1,2,3} I want to define a function TOT[c[i,t]] which, for instance, computes Total[Array]. This does not work: TOT[c[i_,t_]]:=Total[c[i,t]] Any help?
29 views

### Simplest way to export (and import) definitions?

Consider I have this code : f=2 f[1.5]=6 f=4 What is the simplest way to save the array f defined on those three numbers in a file ? (in my case, I will ...
84 views

### Bivariate Array Arrangements

I want to Generate a bivariate data set (X,Y) of m*m Arrange each row with respect to X Note the order of Y associated with X From the first row, pick the first element order of X, along with Y and ...
46 views

### Sum up different arrays into a new array

I have a question regarding sums in arrays. So I have the following array: ...
32 views

### How to run image manipulation function to an array of images?

I have multiple images imported into an array. My issue begins with using this array for an image manipulation function such as Inpaint. Inpaint only accepts a single image at a time. Here's how I ...
108 views

### How to draw individual mesh lines in ArrayPlot

Consider the following ArrayPlot. ...
132 views

### Flatten a four dimensional array into a matrix

What is the simplest way to transform an array of the form ...
46 views

### Generating columns in table and header for exported data file automatically

I have a code that goes like this: ...
74 views

### How do I create a Jacobian matrix for a large system of equations?

I would like to create a Jacobian matrix using the simplified functions below: f1[a_,b_,c_]:= a^2 + b^2 f2[a_,b_,c_]:= c/2 f3[a_,b_,c_]:= b^3 I say simplified ...
548 views

### How to read .npy file in Mathematica?

I have a .npy file which is created by numpy of Python as below:- ...
93 views

### Extracting unique values from array

I performed MorphologicalComponents on an image, and from there used SelectComponents to filter out my desired components. Is there a way to extract out the unique values from the entire array? i.e. ...
132 views

### How can I import a .txt file containing a matrix of numbers and work with its columns? [closed]

I want to import a text file which has two columns. Then I want to assign one column to an array alpha[i]. Using the following command assigns the whole file to t[i]. ...
91 views

### Using good method to produce a regular matrix

The matrixform is as follow, and how can I use good method to produce it? H = {{1, 1, 0}, {2, 2, 0}, {0, 1, 1}, {0, 2, 2}, {1, 0, 1}, {2, 0, 2}}
40 views

### find in list almost equal elements, make new list correspond to position or some list

I have a list of elements called q and wish to compute Total Multiplicity of each element, and put these values in the list tm. ...
540 views

### Sort with assumptions

I have a list which looks like this list = {0, Subscript[x,7], -Subscript[x,3]-Subscript[x,9], -Subscript[x,9]}; and all the $x_i$'s are positive semidefinite (i....
495 views

### Part::pkspec1: The expression j cannot be used as a part specification

I want to do some stuff with symbolic arrays like this a[[j]] + a[[j + 1]] == a[[j - 1]] + a[[j - 2]] But upon declaring such an expression I get ...
82 views

### Drawing an approximate visualization of an inequality using ArrayPlot

I need to write a function that returns graphic visualization of the two-dimensional figure described with equation: $\qquad P = \{(x, y) \in R^2: 4+2x < x^2+y^2<9\}$ I have to use the n x n ...
105 views

### DefineDLLFunction returning array

I have an external "C" DLL function which returns a pointer to an byte array as well as the number of array elements (bytes) ...
278 views

### Converting a list of colors into an image

I want to manipulate colors, and merge the resulting vector and rasterize it into an image, controlling the resolution of the pixel. E.g. I tried to: But what I would like to have is an image of 3 ...
106 views

### Fast and Listable Piecewise function

I am writing a simulation where I have an array with ten columns and on the order of millions of rows, for which I need to iterate on the order of ten thousand times, making computation time a major ...
147 views

### What is the difference between an array and a list

Is there a difference in functionality between a list of lists and an array? In Python sometimes data structures are mutable or immutable. I don't see the difference in Mathematica.
103 views

### Mathematica incorrectly imports a table

I am trying to calculate the eigenvalues of a large matrix (10^4x10^4), which is formed by summing a matrix containing advective terms and a matrix containing diffusive terms. I am using the following ...
45 views

### Make a plot from data [closed]

I have two variables $x$ and $y$ satisfying, say, $y^2 + x < 1$, such that $0 \le x < 1$ and $0\le y<1$. I want to plot all the points satisfying the inequality $y^2 + x < 1$ and also show ...
38 views

### imposing conditions on an array within a function

Let's say I have the following function ...