deleting all the empty rows

13 ビュー (過去 30 日間)
antonet
antonet 2012 年 7 月 13 日
編集済み: Stephen23 2014 年 9 月 25 日
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 件のコメント
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 日
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.
Greg Heath
Greg Heath 2014 年 9 月 25 日
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] []

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by