Divided a matrix into sub-matrices (MATLAB)

4 次查看(过去 30 天)
Dear members;
I have an empty matrix of dimensions (m*n)=(6*12) using:
H=zeros(m,n)
I have to fil this matrix with ones, in order to obtain J=3 ones in each column and K=6 ones in each row.
J=3; K=6;
Firstly, I want to divise this matrix H into J sub-matrices, each sub-matrix contains (n/K) rows and a nonzero element in each column.
Can anyone help me to program this step please

回答(2 个)

KSSV
KSSV 2021-9-8
H=zeros(m,n) ;
J = 3 ; K = 6 ;
H(:,J) = 1 ;
H(K,:) = 1 ;
  1 个评论
Afluo Raoual
Afluo Raoual 2021-9-8
@KSSV Sorry, but that's not what I search for.
Using your code, I dont get the condition that I want ( I want to divise this matrix H into J sub-matrices, each sub-matrix contains (n/K) rows and a nonzero element in each column)

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2021-9-8
Firstly, I want to divise this matrix H into J sub-matrices, each sub-matrix contains (n/K) row
Are you sure about that? n is the number of columns, not the number of rows. It would seem to me to make more sense to divide into J sub-matrices each containing m/J rows.
m = 6; n = 12;
J=3; K=6;
H=zeros(m,n)
H = 6×12
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
split = mat2cell(H, (n/K) * ones(1,m*K/n), n)
split = 3×1 cell array
{2×12 double} {2×12 double} {2×12 double}
Not sure where you want to go from there.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by