The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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.

301 questions
Filter by
Sorted by
Tagged with
14 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 ...
204 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 ...
42 views

How to evaluate an expression [on hold]

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 ...
22 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: ...
45 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 ...
67 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. ...
45 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.
31 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[]: ...
95 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 ...
27 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 ...
72 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 ...
44 views

Sum up different arrays into a new array

I have a question regarding sums in arrays. So I have the following array: ...
31 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 ...
91 views

How to draw individual mesh lines in ArrayPlot

Consider the following ArrayPlot. ...
129 views

Flatten a four dimensional array into a matrix

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

Generating columns in table and header for exported data file automatically

I have a code that goes like this: ...
59 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 ...
354 views

How to read .npy file in Mathematica?

I have a .npy file which is created by numpy of Python as below:- ...
63 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. ...
96 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]. ...
83 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}}
37 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. ...
525 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....
296 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 ...
81 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 ...
102 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) ...
268 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 ...
84 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 ...
107 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 ...
44 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 ...
37 views

imposing conditions on an array within a function

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

How to join many columns of data in array?

I have large number of columns of data. How to put in single matrix? For example, with test data of 1 x 3 matrixs ...
147 views

Fast element-wise division of matrix, generated from vector with Outer, and another matrix

m = {a, b, c}; n = {{e, r, t}, {y, u, i}, {g, h, j}}; k = Outer[Divide, m, m]; k/n gives ...
78 views

Derivative of sum of elements of array [closed]

I try to get derivative of sum of an array with respect to an element of the array. $$s = \sum_{i = 1}^{3}A_{i, 1}$$ Evaluate $\frac{\partial s}{\partial A_{1,1}}$ Below is the code. ...
55 views

Counting the number of Configurations in an Array with Constraints

Consider an array $$\{a_i\}, i=1, ..., N$$ with periodic boundary condition, i.e. $i\equiv i+N$. $a_i\in \{0, 1\}$. I would like to count the number of configurations of the array $\{a_i\}$ satisfying ...
82 views

change color of ArrayPlot

I have de following array: size=5; Initial = RandomInteger[{0, 1}, {size, size}]*2 - 1; to visualize it I use the following code: ...
60 views

How can I modify an element of an array? [closed]

I have a simple array like this one: myArray = {1, 2, 17} At some point I want that 2 to be a 4. How can I change it?
295 views

Which second arguments is VectorQ/MatrixQ/ArrayQ optimized for?

VectorQ and similar functions (MatrixQ, ArrayQ) treat certain second arguments specially. ...
24 views

Plotting an element of large array is slow

I get a slow down when using ContourPlot on elements of a large array of messy expressions. That is, if fooArray has 100 elements and I plot the first 3, that's much slower than if fooArray has 3 ...
65 views

Evaluating the 1st argument of Set

I want to assign a certain value to an element of a tensor. This element is identified by an array obtained from some evaluations, so we fix it. Here i present an oversimplified core part of my code: ...
429 views

Tag Times in Null is Protected [closed]

I've some problems with the error mentioned in the title. Unfortunately, my code is full of subscripts so I'll show it in a photo. In this code the central aspect is to assign a scalar value to an ...
76 views

Position for array

how does Positionwork for array? In particular if i have something like this: ...
41 views

Change value of boundary of a multidimensional array

How can we change the value of boundary of a multidimensional Array with arbitrary rank. I tried to extract the indicies with: ...
528 views

Removing lists with zero at any position

I want to delete the complete list within a list containing 0 at any position. I tried using: ...
476 views

Mathematica equivalent of NumPy broadcast addition for large arrays [duplicate]

What is the Mathematica equivalent of the following Python code with the vectors' broadcast addition? ...