How do I create cell/struct array with the specific lines taken from a text file?
Mostrar comentarios más antiguos
this is the code that i currently working with:
% open the file
fid = fopen('images_list1.txt');
% initialize a lineNumer
lineNum = 0;
% keep reading the file
while 1;
% get a line of text
tline = fgetl(fid); lineNum = lineNum + 1;
% exit if the line is empty
if tline == -1;
break;
end
% check modulus of lineNum for every 2nd and 11th line
if rem(lineNum,13) == 2;
tline_2nd = tline;
%disp(tline);
elseif rem(lineNum,13) == 11;
tline_11th = tline;
%disp(tline);
end
end
May I know how do I create cell/struct arrays with the every two lines I have extracted from my text file. For the first line, I'm extracting the image name with a format of "12345678.jpg" and for the second line, i'm extracting the no. of likes, which i would want it to be in a matrix if it is possible. Much help needed.. thanks!
2 comentarios
Stephen23
el 28 de Oct. de 2015
Can you upload the data file please. It is useful for us to try code on. You can upload a file by clicking the paperclip button and then both the Choose file and Attach file buttons.
Josephine Ng
el 28 de Oct. de 2015
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Workspace Variables and MAT Files en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!