Deleting Empty Rows in Cell Array
    6 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    tinkyminky93
 le 6 Juin 2022
  
    
    
    
    
    Commenté : Fangjun Jiang
      
      
 le 7 Juin 2022
            Hello,
I have a cell array like
'             '
'             '
'1231231'
'             '
'             '
'1231231'
'             '
I want to delete this blank elements and transform this cell array from 7x1 to 2x1. How can I do it? Is there any methods to solve this problem without cellfun or etc.? Thank you.
0 commentaires
Réponse acceptée
  Fangjun Jiang
      
      
 le 6 Juin 2022
        If the data is in a cell array, mostly likely cellfun() is needed, unless you use for-loop.
strtrim() or strip() can remove the white spaces.
b={'             '
    '             '
    '1231231'
    '             '
    '             '
    '1231231'
    '             '};
c=strip(b);
index=cellfun(@isempty,c);
d=b(~index)
7 commentaires
  Fangjun Jiang
      
      
 le 7 Juin 2022
				Provide some example data that others can use directly in MATLAB to help you. For example
'             '
'1231231'
can not be used directly in MATLAB, while
a={'             '
'1231231'}
can so others can use it to provide you with example code.
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Logical dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


