Borrar filtros
Borrar filtros

How to continue execution of textscan if it cannot match formatSpec to the data

1 visualización (últimos 30 días)
34,35,36,
34,35,36,37,
34,35,36,
Let say I have the above 3 lines of data which I am reading using textscan. Let say textscan's formatSpec is '%d %d %d'. Then in this case it stops after 1st data line. So I would like to implement a script which continues with another formatSpec if textscan couldn't match initial formatSpec. How can I do it? The logic is below.
fmt_one = '%d %d %d';
fmt_one = '%d %d %d %d';
C = textscan(fileID,'%d %d %d');
if textscan stopped
C = textscan(fileID,'%d %d %d %d');

Respuestas (1)

Star Strider
Star Strider el 7 de Jun. de 2015
I would use:
C = textscan(fileID,'%d %d %d %d');
adding the appropriate 'Delimiter', 'CollectOutput', 'EndOfLine' and other name-value pairs as required. If textscan encounters a blank space, it should substitute NaN for the missing value.

Categorías

Más información sobre Large Files and Big Data en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by