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
0
votes
1 answer

Scilab code giving submatrix incorrectly defined error

I am trying to plot a 3D graph between 2 scalars and one matrix for each of its entries. On compiling it is giving me "Submatrix incorrectly defined" error on line 11. The code: i_max= 3; u = zeros(4,5); a1 = 1; a2 = 1; a3 = 1; b1 = 1; hx =…
deba123
  • 15
  • 5
0
votes
2 answers

matlab/numpy submatrix contour

I'm looking for a way to get the contour of a matlab/numpy submatrix. For example, if I have : A= [x,x,x,x,x,x,x] [x,x,x,x,x,x,x] [x,1,2,3,4,x,x] [x,5,x,x,6,x,x] [x,7,8,9,10,x,x] [x,x,x,x,x,x,x] Is there a way to get [1,2,3,4,6,10,9,8,7,5] faster…
Nihl
  • 557
  • 1
  • 5
  • 14
0
votes
2 answers

Assigning values to a sub-matrix of a indexed sub-matrix in Matlab

I'm not sure if I've used to correct wording in the Title to describe the problem. Please do feel free to edit it to reflect the description below. Suppose I have a sudoku solver program and lets say the input matrix is the following, A =…
Naveen
  • 458
  • 1
  • 10
  • 29
0
votes
3 answers

how to make a function that take n as argument and create submatrix in matlab

hi everyone i stuck in a problem.i am going to make a function called quadrants that takes as its input argument a scalar integer named n. The function returns Q, a 2n-by-2n matrix. Q consists of four n-by-n submatrices. The elements of the…
0
votes
1 answer

How to calculate Sub matrix of a matrix

I was giving a test for a company called Code Nation and came across this question which asked me to calculate how many times a number k appears in the submatrix M[n][n]. Now there was a example which said Input like this. 5 1 2 3 2 5 36 M[i][j] is…
Saras Arya
  • 3,022
  • 8
  • 41
  • 71
0
votes
0 answers

how to select a submatrix from a matrix in Matlab

I have a large complex matrix A of size 500 * 600, but i need to use only a small submatrix from the matrix A. is there anyway to do that in Matlab 2013R by selecting the start and end range of the rows and columns?
Alladin
  • 1,010
  • 3
  • 27
  • 45
0
votes
2 answers

Is it possible to display all submatrices each represented by a variable in matlab?

Is there any inbuilt function to display all the submatrices from a matrix in matlab? For displaying one submatrix we have the function x(:,m:n). For eg: Consider a 4 x 4 matrix A = 14 11 16 16 15 2 16 8 3 …
0
votes
3 answers

How to extract a 2x2 submatrix from a bigger matrix

I am a very basic user and do not know much about commands used in C, so please bear with me...I cant use very complicated codes. I have some knowledge in the stdio.h and ctype.h library, but thats about it. I have a matrix in a txt file and I want…
NLed
  • 1,845
  • 14
  • 39
  • 68
0
votes
1 answer

Submatrix Indexing and Operations Without Loops

I'm having the following problem: I have a matrix which is 20 x 1000 and I want to divide it into four submatrices of size 20 x 250. After that, I want to make operation to each submatrix assume that I have a vector P of length equal to the number…
0
votes
2 answers

create matrix as having a subset of columns from another matrix

I need to get a new matrix generated by selecting a subset of columns from another matrix, given a list (or tuple) of column indices. The following is the code I am working on (there is a bit more than just the attempt to create a new matrix, but…
fstab
  • 4,801
  • 8
  • 34
  • 66
0
votes
3 answers

How do I subset a matrix by rownames using a list of row headers

I have a list of names (mylist). This list of names coincide with some of the row names in a (much) bigger file, which also contain additional columns of data (bigfile). How can I extract the rows in 'bigfile' matching with the names in 'mylist'?
SigneMaten
  • 493
  • 1
  • 6
  • 13
0
votes
1 answer

Matlab, define submatrix

I got a 10x10 matrix with a bunch of zeroes and an element of the value 1. I'm trying to create a submatrix with the element of 1 and its surrounding. Problem: This is just an example, the element "1" is placed anywhere within the matrix. I do…
0
votes
1 answer

Maximum Submatrix Sum of nxn matrices

I'm trying to get the maximum Submatrix Sum from given nxn matrices. From what I read around the algorithm have a complexity of n^3 (kadane). I tried to implement it in java using a code I found here on stackoverflow (written by Anders Gustafsson in…
Century
  • 285
  • 6
  • 20
0
votes
1 answer

Submatrix in scipy

I have a sparse matrix A and a column vector a, In[1]: A Out[1]: <256x256 sparse matrix of type '' with 512 stored elements (blocksize = 2x2) in Block Sparse Row format> In[2]: len(a) Out[2]: 70 I would to write a submatrix.…
Ornella
  • 3
  • 2
0
votes
1 answer

In R, logical operators and formulae to extract rows from a matrix

In R, let M be the matrix [,1] [,2] [,3] [1,] 1 9 1 [2,] 2 12 5 [3,] 3 4 6 [4,] 6 2 4 I would like to extract a submatrix m from M applying the distinct conditions condition 1: M[,1]<6 & M[,2]>8; condition…
Avitus
  • 734
  • 2
  • 14
  • 27