access data at specific position in cell
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Christian
le 12 Juin 2018
Réponse apportée : Christian
le 12 Juin 2018
Hello everybody,
I’d like to extract values out of a cell. In the beginning the cell (e.g. 1x3) contains other cell arrays, e.g.:
cell{1,1}
„hello“,“world“,500
„hello“,“world“,600
cell{1,2}
„hello“,“USA“,1.5
„hello“,“USA“,1.8
Now I want to code a for loop, which gets me the values after the last “,” in every cell. Right now I’m using this code within a for loop:
Position_komma{:,i} = strfind(cell{1,i}, ','); Position_last_komma{:,i} = cellfun(@(v) v(end), Position_Komma{1,i});
And finally I convert the cells to a cell which does not contain other cells anymore:
cell=[cell{:}]; Position_last_komma=[Position_last_komma{:}];
So cell (now 2x3) looks like this:
„hello“,“world“,500 „hello“,“USA“,1.5 „hello“,“australia“,0.5999 „hello“,“world“,600 „hello“,“USA“,1.8 „hello“,“australia“,0.86
And Position_last_komma (2x3 double) like this:
16 14 20 16 14 20
Finally I need to get every string after the last komma in each cell, but I’m not able, to go into e.g. cell{1,1} and to the 17th digit in there. I hope I made my point clear and someone can help me!
Cheers, Christian
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!