Deleting words [ ] and 'neutral'
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Jan
il 17 Lug 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.
Risposta accettata
Andrei Bobrov
il 17 Lug 2012
Modificato: Andrei Bobrov
il 17 Lug 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!