Delete the Whole Row and Merge The Next Row in a matrix
이전 댓글 표시
I have a Matrix A =
'30' 'X' '@NA'
'15' 'Y' [231.001]
'00' 'Y' [21.110]
'20' 'W' '@NA'
'55' 'X' [9.001]
'10' 'X' [11.211]
>>whos A
Name Size Bytes Class Attributes
aaa 6x3 226 cell
How can I get a new matrix B that delete the whole row of Matrix A if there is anything other than '10','15','20'...'55' in Column 1, or any '@NA' in Column 3 , and MERGE the next qualified row.
Take A for example, Row 1 and 4 should be deleted because there is '@NA' in Column 3. Row 3 should also be deleted because there is '00' in Column 1.
Matrix B should like,
>>B
B =
'15' 'Y' [231.001]
'55' 'X' [9.001]
'10' 'X' [11.211]
B is a 3*3 cell matrix. Any suggestion is welcome!
채택된 답변
추가 답변 (1개)
Azzi Abdelmalek
2012년 8월 8일
편집: Azzi Abdelmalek
2012년 8월 8일
a1=A(:,1);B=A
a1=str2num(cell2mat(A(:,1)))
[i1,j1]=find(mod(a1,5)~=0 | a1<10)
B(i1,:)=[]
ind=cellfun(@(x) isnumeric(x),B(:,3))
result=B(ind,:)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!