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.

Filter by
Sorted by
Tagged with
4
votes
3answers
174 views

Generating signed permutation matrices

As most people (on here at least) know a permutation matrix is a square binary matrix that has exactly one entry of 1 in each row and each column and 0s elsewhere. For the $n \times n$ case there are $...
0
votes
0answers
34 views

How to add many indexed arrays together under each other?

I have some indexed arrays like this f[1] = ConstantArray[a, {2, 3}] f[2] = ConstantArray[b, {2, 3}] f[3] = ConstantArray[c, {2, 3}] I wanna add them together ...
0
votes
1answer
55 views

Part of array as a blank variable [duplicate]

I have a little question. Let me define the function: f[k_]:=k So 'k' in the argument of 'f' is a blank variable. Is there a way to define a part of array as a ...
1
vote
2answers
63 views

Replacing nonzero elements of a matrix with corresponding elements of another matrix

Given an n-by-n matrix A with elements equal to either 0 or 1, I want to replace only nonzero elements (A_ij)'s by (b_ij) and leave 0's intact where (b_ij)'s are themselves elements of another n-by-n ...
2
votes
1answer
54 views

How to create a 3D matrix from different blocks?

I would like to generate a $3D$ matrix of dimension $(n1\times n1\times n1)$ compose of $216$ matrix blocks $(n2\times n2\times n2)$. All 216 matrix blocks are subdivided into 4 groups, each one with ...
3
votes
3answers
145 views

Generating a list of continued fractions

Given positive integers $ k $ and $ n $, I would like to generate a list of all the finite continued fractions of length $ k $ in the interval $ [0,1] $ whose partial quotients are bounded above by $ ...
1
vote
4answers
71 views

Link elements from list to make more lists from certain lenght [closed]

How can I go from this list [36, 73, 84, 0, 73, 83, 0, 69, 69, 78, 0, 84, 69, 75, 83, 84, 31] to this [0000003673, 8400738300, 6969780084, 6975838431]. Is there also a way to make the elements the ...
1
vote
1answer
74 views

How to change Global Preprint preferences for how matrixes are displayed?

I asked a question about how to make all array outputs be displayed as matrices a few weeks ago. I have run into a problem ensuring that the setting change is permanent, however. I thought the global ...
3
votes
1answer
91 views

What is the difference between Catenate and Flatten? [closed]

I am having a hard time understanding the difference between Flatten and Catenate. Consider the following example code: ...
0
votes
1answer
65 views

How to graph a discontinuous array of data

I have an array of data, I am trying to plot it but I need to draw a line each 10 data and displayed as a discontinuous function. I tried using ListLinePlot but ...
0
votes
1answer
33 views

How can I merge indices, such as converting a $4$-index list to $2$-index matrix, $C_{ijkl} \rightarrow D_{(ik); (jl)}$?

How can I merge indices, such as converting a $4$-index list to $2$-index matrix, $C_{ijkl} \rightarrow D_{(ik); (jl)}$? This example sometimes appears in physics applications. Here, I mean $(ik)$ as ...
0
votes
1answer
45 views

How to compose an algorithm to create new array (based on array data), if I need a reference to an array being created, no for loop, in mathematica?

I have an array with either 1 or 0. From this, I am trying to create a new array with intervals. I have some base interval, one step, we can say 1 second here. If there is 0, I skip, if there is 1 I ...
3
votes
2answers
97 views

How to reorder a 3d (m x n x n) array to extract an n**2 length list of sequences of m points

I have a 900x100x100 array of floats called 'data' which is essentially 900 frames of 100x100 pixels. I want to extract 10,000 sequences of 900 values each. These are essentially the time series of ...
0
votes
0answers
42 views

Evaluate an expression with numerical values

I hope this time you guys can help me. I have the following numerical expression: ...
0
votes
0answers
46 views

Replace Array on symbolic expression

Following my previous question: Go back to a symbolic expression to evaluate derivative I've changed my code to keep the symbolic expression. My question now is if there is a way of replacing L1 and ...
1
vote
1answer
65 views

Concatenating matrices using headings

New to Mathematica. I want to create and combine K1, K2, and K3 (shown in the first picture below) into the 8x8 matrix shown in the second picture below and keep the heading as shown if possible: ...
2
votes
1answer
67 views

How to get a specific component of an equation without hardcoding? [closed]

Say I define an equation line[t_] = {t, 2t, 3t}. What code will define x[t] = t, y[t] = 2t, ...
0
votes
1answer
43 views

Function of an array of values with length dependent on another variable

I need to define a function of arbitrarily many variables, whose number is itself a variable of the function. Schematically it would look as following: ...
0
votes
0answers
36 views

Using the for loop in the Module function

Good afternoon, I need some help. I have compiled a function that calculates the flight of the ball, step by step I made an analytical solution first, then a numerical one. But in numerical it is not ...
0
votes
2answers
82 views

How to build my desire matrix using SparseArray?

I have built some lists as follows: ...
1
vote
2answers
87 views

How to link value pairs to formula

I got this formula ...
0
votes
1answer
85 views

How to change a string-formatted element in an array?

I have an array called Array7 in which a typical element, let's say Array7[5][[22]], looks like this: ...
0
votes
0answers
43 views

Check an input matrix M contains any nonzero diagonal matrix element or not

Is there a way to easily check an input matrix M contains any nonzero diagonal matrix element or not? For example, if the M contains any nonzero diagonal matrix element, Output: True. if the M ...
2
votes
0answers
49 views

Partitioned matrices back to array [closed]

mat1 = Table[ If[i > j, RandomReal[], -RandomReal[]], {i, 16}, {j, 16}]; mat2 = Partition[mat1, {4,4}]; Is there a possibility to get the first one from the ...
0
votes
0answers
35 views

$P=QRS$ decomposition of given list-3-unordered list

This is an extended version of my previous posts, $P=QRS$ decomposition of given list, P=QRS decomposition of given list -2 -unordered list Inspired by @Bill, and considering multiplicities, ...
2
votes
3answers
174 views

add columns of list {a0,b0} to columns of list {{a0,b0} ,{a1,b1} ,{a2,b2} ...{ax,bx} } [closed]

If I want to add the columns of {1,2} to each of the columns of say {{1,2},{3,2},{4,2}} resulting in {{2, 4}, {4, 4}, {5, 4}} How would I do this? and for any ...
0
votes
1answer
47 views

P=QRS decomposition of given list -2 -unordered list

This is an extended version of my previous post, $P=QRS$ decomposition of given list Based on the answer and comment of @Bill, Form all permutations of P. Form Q as the first element of each of those,...
0
votes
0answers
24 views

Given sum of sequences, choose two sequence elements and make other sequence zero with making some sequence vanishes and others keep untouched

Slightly modified from my previous question Making function for a given input of sum of sequences, choose two sequence $a_i, b_j$ and substitute all other sequence zero At this time I want to make ...
1
vote
1answer
47 views

How to generate an 3D animation of an evolving 2d square array surface w.r.t time?

I have a data file consists of evolving 2d square array over time. The first block of the 16*16 square array contains the initial values on each of the 256 points. Then the 2nd block is the square ...
1
vote
2answers
39 views

Making function for a given input of sum of sequences, choose two sequence $a_i, b_j$ and substitute all other sequence zero

Suppose I have a sequence a,b,c,d,e,f,g and for given sequence whose element is expressed as a1,a2,a3, ... , c1,c2,c3, ... g1,g2,g3, and so on. And suppose from these sequence with some manipulation ...
4
votes
4answers
222 views

Is there an easy way to copy a TableForm column and convert it into a vector?

Is there an easy way to take a column output from a TableForm command, like this: ...
0
votes
1answer
59 views

Exporting complex exponential float arrays to Python

A question related to a previous question. The answer in the previous question works well for simple complex arrays but not when considering arrays with exponential float coefficients as in the ...
12
votes
1answer
315 views

Most efficient way to shift arrays

I would like to know what would be the most efficient way to shift numerical 2D arrays along its dimensions as follows: (A = Partition[Range[9], 3])//TableForm $$\...
1
vote
1answer
34 views

Insert string elements to an array

(Minimal example) I'm dealing with the following array : ...
0
votes
0answers
34 views

Plot trajectories of 1D coalescing particles: Reshape irregular size array

My question boils down to: How can I reshape a list composed of sublists of different sizes? I am trying to plot the trajectories of 5 particles (1D), and if they collide, they merge into one same ...
2
votes
1answer
137 views

How can I list the common elements of two lists?

The elements of both lists are given as A={9,5,9,3}, B={9,9,5,5} In this case, how can I list the list {9,5,9} of the common elements of the two lists? (The order does not matter.)
4
votes
2answers
141 views
2
votes
0answers
28 views

Implementing array with partial cyclic data?

I'd like to construct an array where some columns are cyclic. As an illustrative example, take Table[Mod[k, 2^i], {k, 2^10}, {i, 0, 10}] //Grid, where the vast ...
0
votes
1answer
27 views

NMinimize is not returning values [closed]

I am new to Mathematica. What is the mistake I am making in the following code snippet? ...
1
vote
1answer
41 views

Reshaping a Matrix [closed]

So i have a matrix like Matrix = $\begin{pmatrix} Mat1 & Mat2 \\ Mat 3 & Mat4 \end{pmatrix} $ Where each matrix mat is a 2x2 matrix mat1= $\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}...
1
vote
1answer
53 views

How to initiate a matrix with indexed parameters [closed]

I couldn't find it in the documentation, so I'm posting it here. I want to create two by two matrices as follows: $$ `W = \begin{bmatrix}w_{11} & w_{12} \\ w_{21} & w_{22} \end{bmatrix}, V = \...
1
vote
1answer
44 views

Replace Part of QuantityArray

I can't figure out how to replace a part of a quantity array. I have: executionList // Dimensions {65, 7} where each row is a QuantityArray: ...
0
votes
1answer
134 views

How to get Sum of array of integers?

This question seems easy but I am struggling with it now, I tried a few ways and check this solution as well but couldn't help me, please check and help if you are able: So I need to save the sum of ...
3
votes
1answer
71 views

Array summation conditioned on maximum and uniques

Given three arrays, for example s={1,3,2,3,1,2,3,2,1} r={4,2,6,5,4,6,2,1,3} f={1,3,9,1,8,4,4,8,2} I'm trying to output four summary arrays The uniques of s For ...
1
vote
1answer
101 views

Exponential Decay fit and printed parameters with integer data [closed]

Problem: I'm trying to plot an exponential decay curve on a set of integer data, and print the various parameters and their uncertainties on the plot itself. Having adapted code from another question, ...
1
vote
1answer
37 views

Eliminate selectively members from an array in Wolfram Mathematica [closed]

There should be a way to do it in Wolfram Mathematica ... I want to eliminate from an array the members that have a corresponding Null on another one. E.g. if I have ...
0
votes
1answer
46 views

Problem with DataRange and PlotRange in ArrayPlot

I have the following ArrayPlot: M = RandomReal[1, {5, 9}]; ArrayPlot[M, FrameTicks -> Automatic, DataRange -> {{11, 19}, {1, 5}}, AspectRatio -> 1/2] ...
4
votes
1answer
139 views

How to generate isotropic tensors?

Consider a real tensor $\bf{T}$ upon $\mathop\otimes\limits_{n}(\mathbb{R}^3)$, with a definite order $n$, it could be isotropic, i.e., be invariant under the action of all elements in $SO(3)$(not $O(...
1
vote
1answer
45 views

Index an array with condition

I have a list like the following: list = {{1, 11}, {2, 7}, {4, 2}, {7, 9}, {-2, 1}}; I would like to select those entries whose second elements are greater than 2, ...
0
votes
0answers
27 views

parallel computation fails

I have a code that evaluates matrix elements. It works correctly in sequential mode (one Kernel). It involves a custom function BariVi which is declared earlier and ...

1
2 3 4 5
8