MATLAB Answers

How to split 1 matrix into 3 parts

4 ビュー (過去 30 日間)
Awab Khalefa
Awab Khalefa 2021 年 5 月 6 日
コメント済み: Awab Khalefa 2021 年 5 月 7 日
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 件のコメント
Awab Khalefa
Awab Khalefa 2021 年 5 月 6 日
Randomly generated values ​​based on row and column data dynamically entered by the user. 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. The matrix produced according to the row and column information entered by the user is shown. The first 1/3 rows of the matrix will be values ​​in the range 0-10, the second 1/3 rows will be values ​​in the range 20-30, and the last 1/3 in the range 50-60. Then, by shuffling all rows (for example, row 1 will be the 10th row in the new matrix, or row 1 will be randomly moved to be the last row in the new matrix), each row will be distances with all other rows and the distance between rows will be calculated for each respective cell. it will be calculated according to the Euclidean relation to match the other cell corresponding to it.
This is the full question and i already did some of it and got stuck
i hope its clearer now

サインインしてコメントする。

採用された回答

KSSV
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
  1 件のコメント
Awab Khalefa
Awab Khalefa 2021 年 5 月 7 日
after that can you help in how to move rows randomly After moving the rows calculate the distance between each row and another row, the distance between them should be written in a new matrix. Thus, the distance results for all lines will be obtained. Finally, rows that are in the same group with each other, depending on their distance, will be displayed in a list.
Thank You Very Much For Your Help.

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by