Creating sub-matrices using one matrix

Let's say I have such a matrix:
A=[1 3;2 4;2 5;0 0;4 5;4 7;0 0;5 6;0 0 ] %I want to divide it into submatrices limiting with [0 0]
B=[1 3;2 4;2 5] C=[4 5;4 7] D=[5 6]
Thank you for your time!

답변 (1개)

Thomas
Thomas 2014년 3월 21일
편집: Thomas 2014년 3월 21일

0 개 추천

댓글 수: 2

Rengin
Rengin 2014년 3월 21일
My question is beyond the extracting randomly rows and columns, meeting a condition to extract sub-matrices limted with [0,0]
Thomas
Thomas 2014년 3월 21일
편집: Thomas 2014년 3월 21일
You could easily find the [0 0] rows and use indexing to get the submatrices..
find(all(A==0,2))
ans =
4.00
7.00
9.00
These are your zero rows .. now index appropriately to create your new sub matrices..

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

2014년 3월 21일

편집:

2014년 3월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by