Borrar filtros
Borrar filtros

fscanf problem with reading data

2 visualizaciones (últimos 30 días)
Ronald Aono
Ronald Aono el 25 de Oct. de 2019
Comentada: Walter Roberson el 29 de Oct. de 2019
FileID =fopen('relp1.dat','r');
formatSpec = '%d %f'; sizeA=[2 Inf];
A = fscanf(FileID,formatSpec,sizeA)
fclose(FileID);
i am trying to scan the following data but it keeps returning an empty value of A
  1 comentario
Walter Roberson
Walter Roberson el 29 de Oct. de 2019
Note that when you use multiple formats like you do, only one data type will be output if the reading works at all. The output is always a single numeric array, and any given numeric array is only a single data type. My tests suggest that everything will be converted to double when '%d %f' is used.

Iniciar sesión para comentar.

Respuestas (1)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi el 29 de Oct. de 2019
Hi Ronald!
Alternatively, consider using the commands ‘readtable’, ‘importdata’ or ‘textscan’ to get your file’s data into an array. These commands offer a lot of options to customize the way you want your data to be parsed.

Categorías

Más información sobre String Parsing 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