How to read Value from .txt

4 visualizaciones (últimos 30 días)
Arun Kumar Singh
Arun Kumar Singh el 15 de Jun. de 2020
Comentada: Arun Kumar Singh el 15 de Jun. de 2020
Here i am attaching screenshot of my file which is in .txt format, i have to read the three values (Marked in the screenshot) from the file. Could you please help me in this ??
  6 comentarios
Walter Roberson
Walter Roberson el 15 de Jun. de 2020
Editada: Walter Roberson el 15 de Jun. de 2020
fopen(), textscan() with headerlines 2, format '%*s%f%f%f', 'collectoutput', true, and count 1 (the count goes immediately after the format and before any other options.) cell2mat() the result of textscan() to get the numeric data. fclose()
Arun Kumar Singh
Arun Kumar Singh el 15 de Jun. de 2020
could you please write the proper code because i am new for matlab .

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Jun. de 2020
filename = 'File.txt';
fid = fopen(filename, 'rt');
GAL = cell2mat(textscan(fid, '%*s%f%f%f', 1, 'headerlines', 2, 'collectoutput', true));
fclose(fid);
  1 comentario
Arun Kumar Singh
Arun Kumar Singh el 15 de Jun. de 2020
Thank you sir, it worked ...

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Low-Level File I/O 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