フィルターのクリア

Find a string from one cell, in a cell array of matrices

1 回表示 (過去 30 日間)
Mat
Mat 2014 年 10 月 31 日
回答済み: Mat 2014 年 11 月 4 日
Been stuck on this step for a few hours now... And stumped.
My data is held in a cell array of matrices. I want to access these matrices, and search the cell number (30,2) in each of these matrices, then tell me which matrix the string was found in
I tried the following, I get :
for i=1:40 % loop through matrices in my cell array
find(strcmp(MyCellArray{1,i}(30,2),'MyString')) % find cell array location of string?
end
  2 件のコメント
Sara
Sara 2014 年 10 月 31 日
I don't understand how your data is arranged. It seems that MyCellArray is n by m cell array, with n = 1 and m = 40. What does each element contain? Another cell array? a string array? Attach it to the post.
Mat
Mat 2014 年 11 月 4 日
Sorry Sara, I hadn't realised you had commented, I normally get an email when an answer is sent... Each cell array element contained another cell array. The higher level cell array contained n=1 and m=40, and the lower levels contained variable rows and 19 columns.
I've eventually found a way to work it, which was:
for i=1:40
a = B{i}(30,2);
isthere{i}=strcmp(a,'mystring')
end
isthere2=cell2mat(isthere);
locationinB=find(isthere==1);
However I've actually scrapped this now in favour of another method.
Thanks for taking the time to comment and apologies I didn't reply until now.

サインインしてコメントする。

採用された回答

Mat
Mat 2014 年 11 月 4 日
This worked
for i=1:40
a = B{i}(30,2);
isthere{i}=strcmp(a,'mystring')
end
isthere2=cell2mat(isthere);
locationinB=find(isthere==1);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by