Deleting words [ ] and 'neutral'
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a matrix of values in command window
result=
Columns 1 through 5
'u' 'u' 'd' 'd' 'gene1'
'u' 'u' 'u' 'u' 'gene2'
'd' 'd' 'neutral' 'd' 'gene3'
'd' 'u' 'u' 'u' 'gene4'
'd' 'u' 'd' 'd' 'gene4'
'd' [] [] 'd' 'gene5'
'd' [] [] 'd' 'gene6'
'neutral' 'u' 'u' 'u' 'gene7'
'd' 'u' 'd' 'neutral' 'gene8'
not i want to delete the word 'neutral' and []
please help
[EDITED, Jan, copied from comments]:
i need output as as
'u' 'u' 'd' 'd' 'gene1'
'u' 'u' 'u' 'u' 'gene2'
'd' 'u' 'u' 'u' 'gene4'
'd' 'u' 'd' 'd' 'gene4'
1 commentaire
Jan
le 17 Juil 2012
What exactly does "delete" mean? Do you want the row to disappear, or the column, or that the elements are move to the left and the empty matrix is inserted at the right?
Because the resulting cell matrix must be still rectangular, "delete" is not well defined yet.
Réponse acceptée
Andrei Bobrov
le 17 Juil 2012
Modifié(e) : Andrei Bobrov
le 17 Juil 2012
EDIT
out = result(all(~cellfun(@(x)isempty(x) | strcmp(x,'neutral'),result),2),:);
or
out = result(~any(cellfun(@(x)isempty(x) | strcmp(x,'neutral'),result),2),:);
3 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices 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!