필터 지우기
필터 지우기

How to make multiple matrices from a single matrix with certain rows and columns?

조회 수: 1 (최근 30일)
Laliguras
Laliguras 2013년 5월 7일
답변: Abhijeet 2023년 2월 10일
Hi,
I have to split a large matrix in multiple submatrices with certain rows and columns. Here is how my matrix named 'test' looks like:
0 10 20 30 40
100 200 300 400 500
200 300 400 500 600
300 500 400 400 400
100 300 300 400 500
Now I need to split it into four matrices with file extension names carrying the first rows numbers (except 0) e.g. test_10, test_20, test_30, test_40 and submatrices as below: test_10 will have 2:5 rows and 1st and 2nd columns, test_20 will have 2:5 rows and 1st and third column, test_30 will have 2:5 rows and 1st and 4th columns and test_40 will have 2:5 rows and 1st and 5th columns. Thank you in advance and I really appreciate your help.

답변 (1개)

Abhijeet
Abhijeet 2023년 2월 10일
Please use the following code format to break matrix into multiple matrices :
matrix = [0 10 20 30 40; 100 200 300 400 500; 200 300 400 500 600; 300 500 400 400 400; 100 300 300 400 500];
test_10 = matrix(2:5, [1, 2]);
test_20 = matrix(2:5, [1, 3]);
test_30 = matrix(2:5, [1, 4]);
test_40 = matrix(2:5, [2, 5]
test_40 = 4×2
200 500 300 600 500 400 300 500
% A sample output of test_40 has been printed for reference

카테고리

Help CenterFile Exchange에서 Hypothesis Tests에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by