How to make multiple matrices from a single matrix with certain rows and columns?
2 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Abhijeet
on 10 Feb 2023
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]
% A sample output of test_40 has been printed for reference
0 Comments
See Also
Categories
Find more on Hypothesis Tests 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!