i have a cell array with string as below (format is "number""space""-""space""number")
1234 - 5678
543 - 2345
5678 - 1234
delete the numbers relations such as
1234 - 5678
5678 - 1234
and keep first one of them and get output as
1234 - 5678
543 - 2345
i need to search using '-'
i get empty matrix, when i do as below
index = find(ismember(cellArr(1), ' - '))

댓글 수: 2

Rik
Rik 2017년 2월 23일
So your question is how to remove the rows with pairs that are descending?
index is empty, because you are comparing a single cell with the text ' - '. I think you should take a look at strfind.
Adam
Adam 2017년 2월 23일
You say you want to delete numbers, but then give an example output which still contains the same first line as I thought you wanted to delete?

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

 채택된 답변

Guillaume
Guillaume 2017년 2월 23일
편집: Guillaume 2017년 2월 23일

2 개 추천

I'm assuming that you want to delete repeated pairs regardless of the order the numbers appear in the pair.
Possibly the easiest way would be:
c = {'1234 - 5678';
'543 - 2345';
'5678 - 1234';}
[~, urows] = unique(regexprep(c, '([^- ]*) - ([^-]*)', '${strjoin(sort({$1, $2}), '' - '')}'), 'stable');
filteredc = c(urows)

추가 답변 (1개)

Pooja Patel
Pooja Patel 2017년 2월 23일

0 개 추천

A(1:2)={rand(10,6)}
A =
[10x6 double] [10x6 double]
>> row=2; A{1}(2,:)=[] %delete 1 row from 1 cell
A =
[9x6 double] [10x6 double]

카테고리

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

태그

질문:

2017년 2월 23일

편집:

2017년 2월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by