How to split 1 matrix into 3 parts
3 ビュー (過去 30 日間)
古いコメントを表示
take from the user the number of rows and column and The first 1/3 row will be values in the range 0-10, the second 1/3 row will be values in the range 20-30, the last 1/3 will be in the range 50-60. so i figured out i have to split the matrix and didn't know how to do that
can anyone help me please ?
2 件のコメント
Jan
2021 年 5 月 6 日
The question is not clear. You get as input the number of rows and columns. Where do the values come from? Which matrix do you want to split?
採用された回答
KSSV
2021 年 5 月 7 日
m = 9; % number of rows (should be multiple of 3)
n = 10 ; % number of columns
p = 3 ; % three parts wanted
% Range of number
R = [0 10;20 30 ;50 60] ;
% Generate the required matrix
A = zeros(m,n) ; % initialize the matrix
for i = 1:p
idx = (i-1)*m/p+(1:m/p) ;
A(idx,:) = (R(i,2)-R(i,1))*rand(m/p,n)+R(i,1) ;
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!