Borrar filtros
Borrar filtros

How to read text files in MATLAB

2 visualizaciones (últimos 30 días)
Jirka Kolben
Jirka Kolben el 4 de Nov. de 2013
Comentada: Jirka Kolben el 5 de Nov. de 2013
Hello, I would like to ask you for help. I have to solve this problem. I have data (textfile) which are outlined bellow and I need to devide data into two cell array. Bold formated data into one cell array and other data into second one. Is it possible to use command textread or any similar command ?? Thank you for all the advice.
  • NM F2 2 620364 1.620040 36.366491 0 1 0
  • GC lead containing glass type
  • ED 8.200000000E+000 9.200000000E+000 3.599000000E+000 2.000000000E-004 0 0
  • CD 1.345333590E+000 9.977438710E-003 2.090731760E-001 4.704507670E-002 9.373571620E-001
  • TD 1.510000000E-006 1.560000000E-008 -2.780000000E-011 9.340000000E-007 1.040000000E-009
  • OD 1.60000 1.00000 0.00000 1.00000 2.30000 1.30000
  • LD 3.20000000E-001 2.50000000E+000
  • IT 3.20000E-001 0.00000E+000 2.50000E+001
  • IT 3.34000E-001 2.11000E-001 2.50000E+001
  • IT 3.50000E-001 7.80000E-001 2.50000E+001
  • IT 3.65000E-001 9.21000E-001 2.50000E+001
  • IT 3.70000E-001 9.40000E-001 2.50000E+001
  • IT 3.80000E-001 9.63000E-001 2.50000E+001
  • IT 3.90000E-001 9.77000E-001 2.50000E+001
  • IT 4.00000E-001 9.85000E-001 2.50000E+001
  • IT 4.05000E-001 9.87000E-001 2.50000E+001
  • IT 4.20000E-001 9.91000E-001 2.50000E+001
  • IT 4.36000E-001 9.93000E-001 2.50000E+001
  • IT 4.60000E-001 9.94000E-001 2.50000E+001

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 4 de Nov. de 2013
Editada: Azzi Abdelmalek el 4 de Nov. de 2013
fid = fopen('file.txt');
res={};
while ~feof(fid)
res{end+1} =fgetl(fid);
end
fclose(fid);
out1=cellfun(@(x) x(1:2),res,'un',0)'
out2=cellfun(@(x) x(4:end),res,'un',0)'

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps 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!

Translated by