Text file to Cell Array

5 visualizaciones (últimos 30 días)
Maroua ROUABAH
Maroua ROUABAH el 3 de Mayo de 2018
Editada: Maroua ROUABAH el 4 de Abr. de 2019
Q01 Grid Bin Group 01 (06x01x20) : Particle Diameter:,0
Q01 Grid Bin Group 01 (07x01x01) : Particle Diameter:,3.01813,2.94369,3.34609,2.91937,2.89348,3.15658
Q01 Grid Bin Group 01 (07x01x02) : Particle Diameter:,3.12845,3.69104,3.59011,3.10082,2.9354..."
DIAM{n,1}=[];
TIME(n,1)=str2num(A{line+1,1});
flag_time=1;
elseif flag_time==1
flag_time=0;
continue
elseif strcmp(A{line,1}(1),'Q')
continue
elseif strcmp(A{line,1}(1),'n')
continue
elseif n>0
DIAM{n,1}=cat(1,DIAM{n,1},str2num(A{line,1}));
end
end
  1 comentario
Guillaume
Guillaume el 3 de Mayo de 2018
In your code, you search for TIME:, yet your example does not have TIME: anywhere in the text.
I there really a comma between Particle Diameter: and the first number?
What you want can be achieved with a regexp but we need to know the exact pattern we're looking for.

Iniciar sesión para comentar.

Respuestas (1)

Ameer Hamza
Ameer Hamza el 3 de Mayo de 2018
Editada: Ameer Hamza el 3 de Mayo de 2018
Try textscan() with these options.
f = fopen(filename)
data = textscan(f, '%s', 'Delimiter', '\n')

Categorías

Más información sobre Characters and Strings 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