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

-1
votes
1answer
33 views

How to create pairwise difference matrix entry?

I have a $16\times 1$ array of integer entries named $H$. How do I create a $16\times 16$ pairwise difference matrix between all entries in array?
3
votes
1answer
73 views

How to use Compile to generate an $n×n$ array using $n$ tensors with both Real and Integer element

This is an extension of my earlier questions Faster use of Condition for a large array (see the example) and How to use Compile to generate an $n\times n$ array using $n$ vectors . In this case each ...
1
vote
1answer
115 views

Export data from Array to *.csv without curly brackets

I have a couple of *.csv files containing data from several experiments. From those, two columns shall be extracted each, to form a new list. This process shall be automated to collect all the data ...
0
votes
0answers
49 views

Solving matrix optimization

I have the following problem. Let $X_1, X_2, \cdots, X_k$ are $n \times n$ Hermitian matrices (need not be positive) given. Let a $n \times n$ positive matrix $A$ is given such that $Tr(A.X_j)<0$ ...
0
votes
2answers
42 views

Defining an array of functions with multiple indices and one variable [closed]

I have a function f of one variable x and a 4 x 3 array ...
2
votes
1answer
103 views

How to use Compile to generate an $n\times n$ array using $n$ vectors

Let's consider the following: ...
2
votes
4answers
204 views

Is there a way to use array of data as a function variable?

I have a data that looks something like. {{1,1},{12,1},{7,9},{10,14}, ...... } I want to see if there is an easy way to apply this array of data into a ...
1
vote
1answer
44 views

Change data form Table to Array

Ok, I am trying to figure out how exactly to change the data from Table such as ...
3
votes
2answers
61 views

An conditional Sum of elements in Array [duplicate]

Consider we have: list = {{2, 3}, {3, 30}, {3, 2}, {4, 53}} and we want to compare the first elements and sum the second elements if first elements are similar ...
1
vote
1answer
67 views

How to specify positions in a matrix by an array?

If I have an array of sets of points such as pts = {{2,4},{1,3},{5,7}} Is there any super short command to use those pairs to output their respective elements in ...
11
votes
3answers
497 views

Subtracting two plots from each other after shifting one

I have the following lists representing energy spectra that need to be subtracted from each other to produce a difference spectrum. ...
0
votes
0answers
66 views

Handling really large Arrays (by possibly using lower precision) [duplicate]

I know there have been a few questions about efficient memory storage on mathematica.stackexchange, but I could not find a sufficient answer for my problem (except that it might not work at all). So ...
1
vote
0answers
51 views

Problems with indexes in a Do-cycle and CoefficientArrays

I have a system of linear equations with variables $A_n$ and need its coefficients in a matrix form (Transform linear system into a matrix form). I'm trying to do that through a ...
0
votes
1answer
191 views

Minimizing using indices, error: Part::pkspec1: The expression cannot be used as a part specification

I want to use Minimize where the variables to minimize are indices pointing into an array. Here a MWE that hopefully shows what my problem is. ...
0
votes
2answers
116 views

recurrence equation, result members don't contain the number 5 [closed]

print the first 5 members of the array a[n+1]=3*a[n]+7 which don't contain the number 5. a1=6. so a[2]=3*6+7=25, but 25 has the number 5 so we go to a[3]. a[3]=25*3+7=82 <--- this is OK... and ...
1
vote
1answer
83 views

How to construct a kernel from a function?

I would like to convolve an image with a mathematical function. I understand that I need to have the mathematical function in a matrix form. How can I build it? Thanks
1
vote
2answers
102 views

Slicing multidimensional table

Say I have a multidimensional list created in the following way grid= Table[{i, j+1, k+2}, {i, 0, 1}, {j, 0, 1}, {k, 0, 1}] grid={{{{0, 1, 2}, {0, 1, 3}}, {{0, 2, 2}, {0, 2, 3}}}, {{{1, ...
4
votes
0answers
59 views

Using indexed array elements as integration dummy variables with EvaluationMonitor. Bug?

As part of a routine that must cope with integration of varying numbers of dimensions, I would like to use indexed variable names (e.g., x[0], x[1],...) as dummy integration variables. However, it ...
1
vote
1answer
93 views

Plot a numerical integration as a function of a variable

Suppose we have a function that is hard to evaluate analytically but a numerical estimate suffices. For example consider the $f(x,\Lambda) = \Lambda\cdot \sin(x)$ where $\Lambda$ is some parameter I ...
0
votes
0answers
39 views

How can I find all stationary points? i.e Something like MinDetect but for saddle points (that applies to data arrays of arbitrary rank)

I would like to find all stationary points of a data set of arbitrary rank. MinDetect and MaxDetect are great for finding minima and maxima but I can't find a good way of finding the saddle points. ...
3
votes
1answer
164 views

How do I create an array by applying a function to the index of each element?

I am looking for something like matrix(m, n, f), but for Mathematica rather than MuPAD, and for arrays rather than matrices. That is, I'm looking for a(n ...
1
vote
3answers
226 views

Writing code to update a large matrix?

How can I write a code to update a matrix based on certain rules? I plan on constructing a large matrix, and I cannot submit entries one by one. The rules for the matrix are as followed: $$ ...
0
votes
1answer
75 views

Calculating a function repetitively without using a For loop

In my programme I have defined all these functions: ...
1
vote
3answers
76 views

Fill an array, symmetric with respect to its centre

I want to create an array that must be symmetric with respect to the centre of it, as in the following example: 0 1 2 3 4 3 2 1 but, instead of having such ...
3
votes
3answers
171 views

Creating a matrix under conditions

I would like to create a matrix whose elements satisfy the following conditions ( Mathematica 9 ) ...
0
votes
1answer
72 views

How to input an adjacency list?

I am a beginner user of Mathematica, and I have an assignment to construct a graph given n (number of vertices) and an adjacency list. My idea was to make a For cycle that repeats n times, and for ...
3
votes
2answers
158 views

Dynamic arrays and lists with compile (Append, Linked lists etc.)

I have a code that I need to compile. The code contains a loop in which I need to gather data into a list. The question is how to best gather data so that the code works inside Compile. The following ...
1
vote
1answer
61 views

How to extract a contiguous s_1 x s_2 x … x s_d subarray from an n_1 x n_2 x … x n_d array, where the dimension d is a variable

Given a multidimensional array, such as the 3-dimensional 2 x 2 x 3 array { {{a,b,c},{d,e,f}}, {{g,h,i},{j,k,l}} } How can I extract an arbitrary 3-dimensional ...
1
vote
2answers
178 views

Manipulating elements of a matrix, to loop or not ?

I have a grid of values generated from a MATLAB evaluation. Most of these elements are 0, some 0.5 and the remainder 1. I'd like to write a mathematica script which reads in the CSV and then, in every ...
0
votes
1answer
59 views

Creating a symbolic function dynamically given an array of data

I have a function that is based on the numeric values of a random sample that I would like to maximize: ...
5
votes
4answers
519 views

Elegant mehod of generating this matrix?

Good evening, I need to determine an elegant (as possible) method of computing an nxn matrix below (the matrix shown is just a 16x16 example). I've been toying with For loops, Tables, Bands, ...
0
votes
1answer
98 views

Export array data into a file

I tried to solve some equation for different values of parameter t and put results into array. Then I wanted to write this data into a txt-file. So i did it with ...
2
votes
2answers
123 views

How do I get all the roots within a certain range for an equation? [duplicate]

I wish to find ALL the roots of the following equation $ x \tan(ax) - c = 0$ within a range, where a and c are constants I control. I've been using ...
4
votes
5answers
300 views

Check whether array has only constant entries?

I have an array arr with n entries. Now I want to check whether ...
0
votes
1answer
57 views

How to split (large) arrays like this?

I want to split this table (list/array) ...
0
votes
2answers
57 views

Getting RandomChoice to work in Manipulate function

I'm a beginner mathematica programmer and I am tryin to create my first demonstration. This code should represent what happens if one changes the size of the reading frame, calculating the nucleotide ...
2
votes
2answers
82 views

How to share numbered variables between kernels

Supose I have two variables v[1] and v[2]. I used: SetSharedVariable[{v[1], v[2]}] Then, ...
1
vote
1answer
79 views

Shifting Columns in an Array Efficiently

I am trying to find a more efficient way to shift the columns of the partitions of an array according to a defined slope and fill in the shifted regions with zeros I have done it below but, I know it ...
0
votes
1answer
67 views

How to assign the array data to variables?

A very basic question but puzzled me for long time on how to assign array to variables. For instance, we have array {{t1,x1},{t2,x2}...{tn,xn}} how to assign the first element to variable t and ...
2
votes
1answer
131 views

ListContourPlot

I am having some issue with ListContourPlot. When I define the following Array: ...
0
votes
1answer
114 views

Array element problem in optimization

I have the following piece of code in Mathematica: ...
0
votes
1answer
30 views

Defining an array using this specific rule [closed]

To a pair of natural numbers $(m,n)$ I would like to associate the $6(m-n+1)\times 2$ array whose rows consist in all pairs $\{x,y\}$ of natural numbers where $m\leq x \leq n$ and $y\in[\lceil x/5 ...
1
vote
1answer
77 views

Entering block matrices, general case doesn't work

I want to enter several matrices at different positions in blocks. There is already a very similar answer here: http://mathematica.stackexchange.com/a/3562/6138 I thought that simply generalizing ...
3
votes
2answers
243 views

Pairwise similarity comparison

I have a 444-member array of arrays called final, with each subarray containing 12 integer members. How can I do a pairwise comparison of the contents of the ...
2
votes
1answer
124 views

Graphic timeline from array

I found this question where someone put some code to graphic a timeline based on a certain number of events. In that code in particular, the events are hard coded one by one, I want to modify it, so ...
2
votes
2answers
68 views

editing entries of a sparse array + sparse Smith normal form

Why does the following code ...
2
votes
2answers
121 views

How to delete certain unwanted elements from an array

Suppose I have an array like so array1 = {{Null,2,3,4,5}, {a,b,c,Null,e}, {w,x,Null,y,z}} Is there some way to selectively remove any element I ...
0
votes
0answers
40 views

Importing large arrays and releasing memory

I am trying to import huge 3 dimensional arrays (in my case approximately 2GB) which I calculated before and saved in .MX format. Then I want to work with a smaller ...
3
votes
1answer
107 views

Fast list interpolation over common x,y for multiple variables

I have a (long, >50K elements) unstructured list with a header similar to; AList[[1]] = {x,y,z,var1,var2,var3,var4,...,varN} I want to interpolate z, var1, var2, ...
0
votes
0answers
59 views

Is there a command like meshgrid in Mathematica? [duplicate]

Just like the title, I need to do a meshgrid in Mathematica, is there any command like that?