Split matrix into multiple matrices with same value
Show older comments
Let's say I have a matrix as with the following values:
A = [1 10
2 10
3 10
4 10
20 1
20 2
20 3
20 4];
then I would like to split this into two separate matrices:
B = [1 10
2 10
3 10
4 10];
C = [20 1
20 2
20 3
20 4];
A is just an example, there could be multiple occasions of the same x or y value. So after C is done there could be more values where either the x or the y value is the same. I want all occasions of same values, either x or y, to be split into a new matrix/new dimension of an existing matrix. Can this be done preferably without a loop? It doesn't really matter that much if it's in a loop though.
1 Comment
Jan
on 22 May 2017
What happens for:
A = [1, 2; ...
1, 3; ...
2, 3, ...
2, 4]
?
Answers (0)
Categories
Find more on Creating and Concatenating 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!