Read .dat file in matlab
Mostrar comentarios más antiguos
I have a .dat mesh file which looks something like this
v 0 1 2 3
v 2 4 5
..
Any idea how I can read the file in matlab and find the number of occurrences of a particular string and also the number of integers in a particular row?
1 comentario
Sandeep
el 4 de Feb. de 2013
Respuestas (1)
Image Analyst
el 3 de Feb. de 2013
Editada: Image Analyst
el 3 de Feb. de 2013
Just read it in line by line with fgetl(). Then use strfind() on each line to see if some sequence of numbers you're interested in exists in the string.
fid = fopen('sandeep data.dat);
tline = fgetl(fid);
while ischar(tline)
disp(tline)
tline = fgetl(fid);
if strfind(s, '2 4 5') > 0
message = 'Found it';
uiwait(msgbox(message));
end
2 comentarios
Sandeep
el 4 de Feb. de 2013
Image Analyst
el 4 de Feb. de 2013
Just count the spaces. The number of spaces equals the number of numbers:
numberOfNumbers = sum(s == ' ')
Categorías
Más información sobre Large Files and Big Data 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!