Questions tagged [submatrix]

A submatrix is a matrix formed by selecting a subset of the rows and columns of one larger matrix. Questions tagged [submatrix] deal with implementation issues regading accessing the relevant rows/columns of the larger matrix, relevant memory issues, etc.

A submatrix is a matrix formed by selecting a subset of the rows and columns of one larger matrix.

For example, let A be a matrix of size n-by-m

A = [ a00 a01 ...
      a10 a11 ...
      .       .
      .        .
      .         .
      an1 an2 ... anm ]

Then one can form a 2-by-3 sub-matrix by selecting rows 2 and 5, and columns 1,4 and 6.
The resulting sub-matrix is then

S = [ a21 a24 a26
      a51 a54 a56 ]

Questions tagged [submatrix] deal with implementation issues regading accessing the relevant rows/columns of the larger matrix, relevant memory issues, etc.

183 questions
2
votes
1 answer

Extract blocks of rows from a single-column dataset to separate sequential columns

I have a dataset that includes all data in 1 column. However a new sub-dataset occurs every n rows. Using MATLAB, I need to grab each of these sub-datasets and place in a separate sequential column. For example, this: Column…
user3743235
  • 159
  • 8
2
votes
1 answer

Problems when extracting a submatrix

I am writing a piece of code to extract a submatrix from a matrix. As modules, I imported scipy and Image. When I run the script, I got the error submatrix = im[x_min:x_max, y_min:y_max] TypeError: an integer is required I checked and the min and…
albus_c
  • 6,292
  • 14
  • 36
  • 77
2
votes
2 answers

Submatrix in C++

I have a programming issue regarding the extraction of a subimage (submatrix) from a bigger image (matrix). I have two points (upper and lower bound of the subimage i want to extract) and i want to extract the subimage from the bigger one based on…
mad
  • 2,677
  • 8
  • 35
  • 78
2
votes
4 answers

How to take part of matrix if unknown number of dimension in Matlab?

Suppose I want do something similar to image(1:end-1,2:end,:) which here is taking part of colored image but with unknown number of dimensions, i.e. which will work automatically like image(1:end-1,2:end) for 2…
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
2
votes
1 answer

Storing output from nested for loops in r

I feel like I should have found/understood the answer to this by now after frequent searches and lots of forum reading, but it's still really confusing to me. I have two nested for loops in r and need to save the output to a variable but I don't…
Misc
  • 645
  • 1
  • 7
  • 20
2
votes
3 answers

In R, using `unique()` with extra conditions to extract submatrices: easy solution without plyr

In R, let M be the matrix [,1] [,2] [,3] [1,] 1 2 3 [2,] 1 3 3 [3,] 2 4 5 [4,] 6 7 8 I would like to select the submatrix m [,1] [,2] [,3] [1,] 1 3 3 [2,] 2 4 5 [3,] 6 7 …
Avitus
  • 734
  • 2
  • 14
  • 27
2
votes
3 answers

MATLAB: How to calculate (on) Submatrices without a loop

I want to split a matrix columnwise into 3 segments and do a calculation on it (mean()). Is there a way to get this without a for-loop, as I did in this provided sample? M = [2 4 9; 50 50 200; 30 0 0]; M = [M 10*M] N = length(M); seg = 3 % split in…
Massoud
  • 175
  • 1
  • 7
2
votes
1 answer

Sum of submatrices of bigger matrix

I have a big matrix as input, and I have the size of a smaller matrix. I have to compute the sum of all possible smaller matrices which can be formed out of the bigger matrix. Example. Input matrix size: 4 × 4 Matrix: 1 2 3 4 5 6 7 8 9 9 0 0 0 0 9…
Bruce
  • 945
  • 3
  • 12
  • 24
2
votes
1 answer

Issue with OpenCV submatrix (type short)

I have an issue when creating a new (sub)matrix that is taken from a bigger matrix and I was hoping someone could lend me a helping hand. I have narrowed the problem down to the following small code snippet: cv::Mat* rightBestX; rightBestX = new…
Wilrik
  • 60
  • 1
  • 5
1
vote
2 answers

Smallest Submatrix in python

It contains an R*C matrix with unique digits. I have to print the submatrix having minimum and maximum integer Input: 5 6 73 31 19 10 27 12 82 66 15 23 64 89 17 40 74 41 99 38 46 79 91 28 57 35 94 97 45 55 33 56 Output: 10 27 23 64 41 99 The…
Akash G S
  • 39
  • 6
1
vote
1 answer

converting isSubMatrixFull function from Python to JS

I am trying to convert(as close to original(Python in this case)) as possible the following function from Python to JS. def getCol(mat, col): return [mat[i][col] for i in range(3)] def isSubMatrixFull(mat): n = len(mat[0]) ans =…
tseeker
  • 79
  • 9
1
vote
1 answer

Numpy create a 2-d array of sub-blocks

I have a set of (numpy) 2d arrays of size N Each element is a 2d numpy array like set_of_arrays[7] == array([[ 5, 3], [ 1, 5], [ 8, -1], [ 6, 6]]) set_of_arrays[123] = array([[ 5, 3, 1, 5, 8, -1, 6, 6], [ 5, 3,…
Terzi Ak
  • 11
  • 1
1
vote
0 answers

Rotate 3D Submatrix Matlab

I would like to rotate a cube that is a submatrix, so i only want to rotate this submatrix. How i can do this? This is the code: clear all close all Dimension = 256; background = zeros(Dimension,Dimension,Dimension); cubo1 =…
1
vote
1 answer

Filter rows by value unless no row meet condition

In R I have the following dataset and I would want remove rows if Per<98, unless no rows with the same value in A meet this condition (then add 0): df <- cbind(c("D1", "D1", "D1", "D1", "D2", "D2", "D2", "D2", "D3", "D3", "D3", "D3"), c(99.8, 99.5,…
RIA
  • 11
  • 1
1
vote
0 answers

How can import some sub-matrix (sub-array2D) and create a matrix (array2D) according to them with a nested loop in python

I generated 4 sub-matrix(block) data and I want to import them to matrix "X" X = np.array((10,10)) and they are sub-matrix sub-matrix into X row_number=[8,2] column_number=[6,4] n = (row_number).T@column_number My problem is How can…