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.

learn more… | top users | synonyms

3
votes
1answer
64 views

Draw border around constant regions of image

I would like to ask that is it possible to draw borderline - contour - around those cells (pixels) which are neighboring and contains the same value. An example by hand: Thanks!
1
vote
1answer
67 views

How to do abstract matrix operation?

In this simple example, I have 2 lists, each of which contains 3 matrices。 $J$ here is also a matrix with the same dimension. What I want is $aJc+bJ(b+c)$, but if I use dot product, the result is as ...
0
votes
0answers
37 views

Easier way to input Dynamic matrix?

I've only been using MMA for a month, and I'm working on making interactive Linear Algebra examples that will be used online for students. Right now, for inputting numbers into a matrix, I've been ...
4
votes
0answers
73 views

Why isn't SparseArray working in this case?

This works: SparseArray[{{1, 1} -> 1, {2, 2} -> 2}]\ (* {{1, 0}, {0, 2}} *) This works: ...
1
vote
0answers
78 views

Speed differences between Table, Replace, Array, Map, and AssociationMap

EDIT: Actually, it looks like part of this is bogus—Array doesn't actually work on this input (I'm often a little shaky on what kind of input, exactly, works for ...
0
votes
2answers
96 views
3
votes
0answers
34 views

How does ContourDetect work for arrays?

By the Wolfram Documentation, ContourDetect gives a binary sparse array in which 1 corresponds to zeros and zero crossings in an array. However, in the example: ...
0
votes
1answer
52 views

How to avoid repeatedly entering a point into an expression [closed]

I have this snippet: points = CirclePoints[{10, 0}, 4]; The result will be an array of 2D coordinates. ...
0
votes
1answer
41 views

Replace elements of array [duplicate]

I have an array of elements and want to assign each element a specific value from a vector, at the same time I need the function ni[i] for the ith element of the list. I tried this, but it doesn't ...
0
votes
3answers
122 views

How to initialize downvalues from a list?

The For expression below initializes downvalues of a variable a from the values in a list ...
0
votes
1answer
22 views

Dynamically constructing symbolic tensors

Is there any way to construct tensor of any given dimension d and rank r with symbolic entries? i.e., instead of manually constructing one as Table[T[i,j,k],{i,1,10},{i,1,10},{i,1,10}] for d=3 and r=...
3
votes
1answer
53 views

Constructing tensors with arbitrary rank and dimension [closed]

How can I create a tensor with arbitrary rank n and m components in each dimension? I am looking for a command in which I insert n and m and it spits out the corresponding tensor with random entries (...
0
votes
1answer
51 views

Reduce array to specific amount of averages [closed]

The main issue which needs to be solved is: Let's say I have an array with 8 numbers, e.g. [2,4,8,3,5,4,9,2] and I use them as values for my x axis in an coordinate system to draw a line. But I can ...
0
votes
3answers
83 views

How can I create a four dimensional plot (3D space + color) of the data provided? [duplicate]

I would like the x, y, and z axes to be reserved for the first three columns and the color to be reserved for the fourth column. I would like the output to have a color bar and color function. If you ...
1
vote
2answers
46 views

TexForm List with Rule

I'm having some difficulty TexForming a list. The output is not what I want. The following is a minimum working example. I've tried every combination of Flatten, ArrayReshape, and Partition to no ...
1
vote
0answers
36 views

Find best convex approximation of an “almost convex” function

I've got values of a function of two variables at integer points inside a rectangle, that is, a rectangular table $f(i,j)$, $1\leqslant i\leqslant m$, $1\leqslant j\leqslant n$. The function is very ...
0
votes
1answer
33 views

Iterating KroneckerProduct[] and returning the result from a function

I am trying to write a function which will take a matrix m and an integer i as inputs. Then it will compute the Kronecker product of m with itself i times and return the result. The code is as follows....
0
votes
4answers
51 views

insert elements into 2 D array [duplicate]

say I have a 2 dimensionsal array like a={{1,2,3},{4,5,6},{7,8,9}} and a vector like v={10,11,12} I want the result to be ...
1
vote
1answer
54 views

Rearrange the list with some rules

I am trying to solve physic problem on operators which are not commute. However, I am not good at coding, so I am having some problem with Mathematica code. Let's define my list such that ...
0
votes
1answer
66 views

Append[] is not working for empty list [duplicate]

I am trying to create an empty list and add an element but the list is not being populated. My code ...
-1
votes
1answer
91 views

Lattice model array for distribution of energy [closed]

Edited for clarity I am trying to make a 2-D array constant, lets say 100x100, and perform a function on that. The array would look like ConstantArray=[1,{100,100}]...
0
votes
1answer
57 views

Calculation of the mean of array data points lying under a predefined rectangle

I have data points in an array, and a predefined rectangle lying within the area of my array. My goal is to calculate the Mean ...
0
votes
1answer
95 views

How to ListContourPlot a functional eigenvalue spectrum?

We have a (Hermitian) matrix of some finite dimension (n) whose elements are functions of real variables x and y. We wish to plot contours of the spectrum (level sets of the n real eigenvalues) at ...
0
votes
0answers
31 views

Simplify expression?

Suppose I have expressions that involve terms like: p1.p1+p2.p2+p3.p3+p4.p4 p1, p2, p3, and p4 are all elements of an array: ...
3
votes
2answers
58 views

Numbering indices / array element positions while creating an array (using 3 argument form)

I am new to Mathematica and trying to create a list that I can use within the InterpolatingPolynomial function. e.g. ...
0
votes
0answers
52 views

Splitting an Array

Background: I'm a fairly experienced programmer, but new to Mathematica I have an image analysis function I have created, which returns a multidimensional array that I do some processing on. I want ...
1
vote
1answer
71 views

making Max and Min work columnwise like Median

I have some data and the rows are grouped according to astGroupsPos (the astGroupsPos are just rows from ...
1
vote
1answer
48 views

Array Flattening arrays of matrices given by rules

Fix an $n$ and an $m$ positive integers.I have some set of four $n\times n$ matrices $A$,$B$,$Y$,$Z$ (where $Z$ is the zero matrix). I'd like to input the $nm\times nm$ matrix of block matrices given ...
2
votes
2answers
77 views

Multiplying a table with constants

I have a table with coordinates {{x1,y1},{x2,y2}} that I want to multiply with a separate constant for x and one for y so: ...
1
vote
0answers
62 views

Finding correct combination of functions

I am trying to write code where I have an array $S$ or numbers in any order [5,4,2,1,....] Then I have a specific set of functions that I can write. ...
15
votes
2answers
307 views

Which elements of a large array are part of a set?

I have a large integer packed array arr. My array is multidimensional, but for simplicity let's consider 1D arrays for now. ...
3
votes
3answers
177 views

Optimizing a series of basic matrix operations—scaling doesn't seem right with matrix size

I have a simple operation that I'd like to apply to an n×n matrix. My problem (well, one of them...) is that it runs in, say, 4 seconds for a 100×100 matrix, but it took five and a half minutes to run ...
1
vote
1answer
76 views

How to find the detailed Dimensions information of a list

In 5 digital images I have determined the 2d coordinates of detected objects. The resulting array (list) can be downloaded from here: http://pastebin.com/7bE0CEJ5 ...
3
votes
5answers
579 views

Finding center of mass in a 2D array

I have a 57x57 array with some integer values in it: ...
1
vote
2answers
81 views

Sum of a set of elements in a array?

For a function I do this (Integrate over circular range): NIntegrate[x*y Boole[Sqrt[x^2 + y^2] < 3], {x, 1, 5}, {y, 1, 5}] ...
1
vote
1answer
95 views

Using a table as a variable in a function

I have a bunch of arrays and need to extract specific rows and columns of these that obey certain criteria. So for one table I'd do like this ...
0
votes
1answer
69 views

Getting numerical values from integrated interpolating function [duplicate]

I have a list of data. I integrate them with interpolation. Lets say is the following: InterpolatingFunction[{{0.01, 4.82}}, <>][x] However, is that ...
1
vote
2answers
118 views

Trouble adding elements to array [closed]

I need to generate array and export it to file. For n = 1 , second element must be 0 For n = 2.. 819, second element must be 1 For n = 820.. 1637, second element must be -1 For n = 1638.. 16384, ...
5
votes
1answer
99 views

ListConvolve with Padding -> Fixed?

The built-in function ImageConvolve takes a Padding option that "specifies what padding to use when extending beyond the ...
2
votes
1answer
51 views

Create array of “positions”

How do I create an array a of generic depth $n+1$, such that exactly: a[[i1]][[i2]]...[in]] = {i1,i2,...,in} ? In words, such ...
1
vote
1answer
99 views

Using ReadList to import specific arrays of a multi-dimensional variable

Consider a large numerical variable (almost 1GB) which was constructed like below: output={scalar1,{Matrix1,Matrix2,Matrix3,scalar2}}; I used ...
2
votes
0answers
57 views

Arrays with two different types of indices

Is there a way of having arrays which have, so to speak, two different depths $m,n$? From the point of view of memory usage, it would be the same as an array of depth $m+n$, but I would like to ...
1
vote
1answer
26 views

Evaluate function entrywise on high dimensional array [closed]

I have defined a function $f$ from number to number. I want to tell Mathematica to apply that function to each entry of a high dimensional array $A$, to get a new array $f(A)$ in the same form of $A$. ...
2
votes
0answers
83 views

Dynamic array in Mathematica like malloc in C++

I have a table to describe a crossroad. Each traffic line has it own Q(flow), V( speed) and direction. I'm saving data in array, which hardcoded (very simple code data = {{66, 55, 3}, {44, 33, 2}, {...
4
votes
1answer
201 views

Drawing a RegionPlot but for data instead of a function

I am trying to draw something similar to RegionPlot, but instead of functions I only have data matrices. For example, I have the following 3 pieces of data (...
0
votes
0answers
40 views

Could not access a specific element of ConstantArray, why ? partw error [duplicate]

I could not access a specific element of ConstantArray, why ? The following is piece of my code: ...
0
votes
1answer
88 views

How to store value of result in an array for a calculation inside the loop [closed]

Note: In my code I used j (ranging from 3 to 7) but I want j to be general I tried this ...
1
vote
1answer
99 views

How hard is it to export numbers that can be used in other programs? [duplicate]

I am calculating a few lists of values that I have in arrays. I want to export these into a tab-delimited text file that I can import into other programs for analysis, plotting and so on but I am ...
3
votes
3answers
183 views

How to test if elements of an array are real or complex?

I am new to Mathematica and I have to select the elements in an array that only contain real numbers and eliminate the ones that have complex parts. Basically the code that I have is an array of ...
10
votes
1answer
223 views

Fast way to pass an array of integers to Java using JLink

I am using a package from java to compress a list of integers, this package provide me two methods, one for compress and other one for uncompress. Each of these methods has a version to ...