Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

4
votes
1answer
75 views

How to draw individual mesh lines in ArrayPlot

Consider the following ArrayPlot. ...
1
vote
2answers
120 views

Flatten a four dimensional array into a matrix

What is the simplest way to transform an array of the form ...
0
votes
1answer
36 views

Generating columns in table and header for exported data file automatically

I have a code that goes like this: ...
0
votes
1answer
50 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 ...
6
votes
2answers
151 views

How to read .npy file in Mathematica?

I have a .npy file which is created by numpy of Python as below:- ...
0
votes
1answer
52 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. ...
0
votes
1answer
71 views

Creating a table with a set length [on hold]

I would like to create a list/table/array that starts at 0 and goes up by increments of 0.25 until it reaches a set length "l". I have tried the Table function, but the imax will vary depending on ...
1
vote
2answers
75 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]. ...
2
votes
2answers
77 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}}
0
votes
1answer
30 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. ...
6
votes
4answers
514 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....
0
votes
1answer
107 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 ...
1
vote
1answer
73 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 ...
2
votes
1answer
91 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) ...
4
votes
3answers
236 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 ...
2
votes
1answer
60 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 ...
0
votes
0answers
58 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.
2
votes
1answer
101 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 ...
1
vote
1answer
43 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 ...
0
votes
1answer
36 views

imposing conditions on an array within a function

Let's say I have the following function ...
4
votes
5answers
435 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 ...
5
votes
2answers
133 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 ...
0
votes
1answer
51 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. ...
2
votes
2answers
51 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 ...
1
vote
1answer
48 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: ...
1
vote
0answers
55 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?
23
votes
1answer
293 views

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

VectorQ and similar functions (MatrixQ, ArrayQ) treat certain second arguments specially. ...
0
votes
0answers
23 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 ...
1
vote
1answer
62 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: ...
1
vote
1answer
283 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 ...
0
votes
1answer
70 views

Position for array

how does Positionwork for array? In particular if i have something like this: ...
1
vote
2answers
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: ...
9
votes
3answers
497 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: ...
10
votes
2answers
460 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? ...
4
votes
2answers
245 views

Populating an array in do loop, allocating memory or not

I am doing a calculation where I have a do loop can be as long as 1 million. In each loop, I want to store a value into an array to plot afterward. In MATLAB normally I was preallocating the memory ...
2
votes
1answer
179 views

Flatten a list at some level

I wonder if is possible flatten a list at the last level without flattening at the first level, I think that isn't a good explanation so here is my code ...
0
votes
0answers
35 views

matrix perturbation general formula with random values

Is there a way to generate an arbitrary-sized diagonal matrix of variables, not numbers, in mathematica? Probably unnecessary context: For a research question I'm pursuing, I want to find general ...
4
votes
2answers
256 views

Handling arrays

Is there a way to transform a matrix in a vector, where you choose the order of the arrangement? I used ArrayReshape but this command chooses its own arrangement, ...
6
votes
2answers
153 views

How to create non-rectangular array with Array?

From the answers to this question, I learned that the recommended way to construct a symbolic sum of terms in an expression is to use Array. But I'm having a ...
4
votes
1answer
122 views

Append to a list piecewise

Is there a way to append piecewise for example list = {{1,2,3},{v,w,x},{a,b,c}} Then append a list which ...
0
votes
1answer
77 views

Loss of 1 to 1 mapping due to duplicate in Association

The main goal of this procedure is to first rotate an array of 3D coordinate leaving z untouched,finding the positions of tuples with z larger than some value, and then mapping those positions to the ...
2
votes
1answer
125 views

How to import and array of data?

I'm trying to import many files which have the same name "x.data", but they end with a extension "x_code1.data". I was trying to import all files with the routine: ...
7
votes
2answers
148 views

Constructing expressions using Sum vs Array[… Plus] vs Plus@@Table[…]

For constructing a sum of terms which are symbolic, I noticed that in addition to ...
13
votes
3answers
547 views

Convert QR code to a Nonogram puzzle

I remember there was a GCHQ puzzle where Nonogram was created to generate a QR code in 2015. It was a quite popular puzzle. I am wondering if MMA can be used to create a Nonogram from an existing QR ...
5
votes
3answers
90 views

Efficiency in array element replacement

Suppose I have two lists: ...
8
votes
3answers
120 views

Creating a random matrix of no duplicates in both row and column from a given set list of elements

Say I have a list of letters {A,B,C,D,E,F,G,H}, I want to create an $4\times 8$ array where each row must not contain duplicates and each column must also not contain duplicates. Naively writing: <...
1
vote
0answers
45 views

Mapping over array/matrix the efficient(compact) way

Update In short, I have myCAans[[1 ;; 5]] like this: {{0, 0, 0, True, 0, 0, 0, 0, True, 0, "T0", 39}, {0, 0, 0, True, 0, 0, 0, 1, True, 1, "B", 101500}, {...
6
votes
3answers
296 views

How to re-scale a matrix column and show the matrix in one line?

I have p = {{a, b, c}, {d, e, f}, {g, h, i}}; and q = p;, is it possible to combine the following 2 lines into 1 line (without <...
4
votes
1answer
55 views

Apply ParallelMap to function f over a matrix while passing as arguments the row number and the element index

I have a matrix test = { {2.5,1.4,3.3},{4,4,4},{7,3.2,9}} and a function f that requires 2 arguments, the row number and the ...
3
votes
1answer
68 views

Elegant method of arranging several aligned plots with specified empty elements

I want to display a series of plots that are aligned, but with certain array positions being empty. If I generate an array of plots like this: ...