Dear all,
I have
[N,T,R]]=xlsread(name);
I want to erase all the empty rows in T.
I suggest
T( all(cellfun(@isempty,T),2), : ) = [];
Am i correct?

댓글 수: 3

per isakson
per isakson 2012년 7월 13일
YES
antonet
antonet 2012년 7월 13일
cheers per
Stephen23
Stephen23 2014년 9월 25일
편집: Stephen23 2014년 9월 25일
A little speed-up that is sometimes worth keeping in mind:
T(all(cellfun('isempty',T),2),:) = [];
There are some special cases (which run faster), where the functions can be supplied as a string. See the cellfun docs for more info.

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

답변 (1개)

Greg Heath
Greg Heath 2012년 7월 13일

1 개 추천

I don't think MATLAB allows empty rows or columns
>> A = [ 1 2 3; [] [] [] ; 7 8 9 ]
A = 1 2 3
7 8 9
>> A = [ 1 [] 3; 4 [] 6; 7 [] 9 ]
A = 1 3
4 6
7 9
>> A = [ [] 2 3; 4 [] 6; 7 8 [] ]
A = 2 3
4 6
7 8
Hope this helps.
Greg

댓글 수: 2

Nirmal
Nirmal 2012년 7월 13일
편집: Nirmal 2012년 7월 13일
T in this case is cell array not the matrix and the cell can have empty string.
Correct:
>> A = { 1 2 3; [] [] [] ; 7 8 9 }, B = { 1 [] 3; 4 [] 6; 7 [] 9 }, C = { [] 2 3; 4 [] 6; 7 8 [] }
A = [1] [2] [3]
[] [] []
[7] [8] [9]
B = [1] [] [3]
[4] [] [6]
[7] [] [9]
C = [] [2] [3]
[4] [] [6]
[7] [8] []

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

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

질문:

2012년 7월 13일

편집:

2014년 9월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by