Extract specific column information from table
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Francisco
le 22 Mar 2016
Commenté : Francisco
le 22 Mar 2016
Hi all, Maybe you could help me with the following?
I have several *.txt files with 3 columns information, here just an example of one file:
namecolumn1 namecolumn2 namecolumn3
-----------------------------------------------------------
name1.jpg someinfo1 name
name2.jpg someinfo2 name
name3.jpg someinfo3 name
othername1.bmp info1 othername
othername2.bmp info2 othername
othername3.bmp info3 othername
I would like to extract from "namecolumn1" only the names starting with name but from column 1.
My code look like this:
file1 = fopen('test.txt','rb');
c = textscan(file1,'%s %s %s','Headerlines',2);
tf = strcmp(c{3}, 'name');
info = c{1}{tf};
the problem is that when I do disp(info) I got only the first entry from the table: name1.jpg and I would like to have all of them:
name1.jpg
name2.jpg
name3.jpg
Thanks a lot in advance!
0 commentaires
Réponse acceptée
Walter Roberson
le 22 Mar 2016
info{1}(tf)
Note: you are using what MATLAB calls a cell array. In MATLAB a table is a different data structure.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Environment and Settings 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!