Borrar filtros
Borrar filtros

read only the numerical value of a file

2 visualizaciones (últimos 30 días)
Mohammad
Mohammad el 15 de En. de 2018
Comentada: Star Strider el 15 de En. de 2018
Hi, I have a file which is attached. I just want to read the number in it and store it in a variable. Thanks for your help.

Respuesta aceptada

Star Strider
Star Strider el 15 de En. de 2018
This works:
filename = 'out_log_test-weak.txt';
fidi = fopen(filename,'rt');
D = textscan(fidi, '%*s%f%%', 'HeaderLines',1);
number = [D{:}]
number =
90.0800
  11 comentarios
Mohammad
Mohammad el 15 de En. de 2018
I was already testing the other command, fscanf, which caused the prevention of accessing the file. Restarting MATLAB solved the issue !
Star Strider
Star Strider el 15 de En. de 2018
Thanks! This information could help if others have the same problem.
Restarting MATLAB might not have been necessary, though. Running:
fclose('all');
from your Command Window could have worked.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by