Divided a matrix into sub-matrices (MATLAB)
9 views (last 30 days)
Show older comments
Answered: Walter Roberson on 8 Sep 2021
I have an empty matrix of dimensions (m*n)=(6*12) using:
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.
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
KSSV on 8 Sep 2021
J = 3 ; K = 6 ;
H(:,J) = 1 ;
H(K,:) = 1 ;
Walter Roberson on 8 Sep 2021
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;
split = mat2cell(H, (n/K) * ones(1,m*K/n), n)
Not sure where you want to go from there.
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!