Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Sara
Sara il 31 Ott 2014
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 il 4 Nov 2014
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.

Accedi per commentare.

Risposta accettata

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

Più risposte (0)

Categorie

Scopri di più su Characters and Strings 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!

Translated by