Deleting words [ ] and 'neutral'

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

Jan
Jan 2012년 7월 17일
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.

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

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 7월 17일
편집: Andrei Bobrov 2012년 7월 17일

0 개 추천

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

Pat
Pat 2012년 7월 17일
Andrei as per your code i get values in single column,if i reshape after that i get error ,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'
please help
Andrei Bobrov
Andrei Bobrov 2012년 7월 17일
편집: Andrei Bobrov 2012년 7월 17일
My answer was edited.
Jan
Jan 2012년 7월 17일
result(any(cellfun('isempty', result) | strcmp(result, 'neutral')), :) = [];

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

질문:

Pat
2012년 7월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by