Extract specific column information from table
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Francisco
el 22 de Mzo. de 2016
Comentada: Francisco
el 22 de Mzo. de 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 comentarios
Respuesta aceptada
Walter Roberson
el 22 de Mzo. de 2016
info{1}(tf)
Note: you are using what MATLAB calls a cell array. In MATLAB a table is a different data structure.
Más respuestas (0)
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!