finding specific string in cell arrays
이전 댓글 표시
I have a set of alphabet, like: alph={a,b,...,z} And Also a cell array named "repo" in which different combination of alphabets exist and each combination has a value, like:
'x y' 2
'r t' 4
'a b' 1
this array is very big. I want to find different combination of my alphabet in this array and extract the value of it. Note that the array does not contain all the combinations of my alph-set. For example it may does not have 'x b' at all (but we don't know if it exist or not).
I wrote the following code. But I want to avoid for-loop, because it is too slow. Do you know any efficient and fast way?
for i=1:size(alphabet)
for j=i:size(alphabet)
str_tmp = strcat(alphabet(i,1), {' '},alphabet(j,1));
index = find(strcmp(str_tmp,repo(:,1)));
saveSomeWhere = str2double(cell2mat(repo(index,2)));
end
end
Many thanks,
댓글 수: 8
Azzi Abdelmalek
2016년 3월 29일
for the posted example, what is the expected result?
Shima Asaadi
2016년 3월 29일
Azzi Abdelmalek
2016년 3월 29일
Where is the example?
Shima Asaadi
2016년 3월 29일
Azzi Abdelmalek
2016년 3월 29일
I didn't ask you to post all your data, just a short example, then post the expected result. How are we supposed to answer if you are not able to show us the expected result?
Shima Asaadi
2016년 3월 29일
편집: Shima Asaadi
2016년 3월 29일
Azzi Abdelmalek
2016년 3월 29일
Let us take just this cell array
M={'"' '0'
'"business-as-usual"' '0'
'"celebration,"' '0'
'"cuddly-feely"' '2'
'"detainees"' '2'
'"exemplary"' '4'
'"family"' '4'
'"force"' '0'
'"frighten"' '0'
'"hyperbole,"' '0'}
What are you expecting from this cell array? can you post the expecting result, and explain how to obtain it?
Shima Asaadi
2016년 3월 29일
편집: Shima Asaadi
2016년 3월 29일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!