using fscanf in the optional range

Hi guys,
I have a homework and ı can not use fscanf function in the range that ı wanted, I have a text like that,
NYC 12.05.2020 01:00 20
NYC 12.05.2020 02:00 22
NYC 12.05.2020 03:00 22
NYC 12.05.2020 04:00 21
NYC 12.05.2020 05:00 23
NYC 12.05.2020 06:00 24
NYC 12.05.2020 07:00 25
NYC 12.05.2020 08:00 29
I want to move degrees located end, to new text file so ı have to extract degree from this text file so ı need fscanf or fgetl functions I tried to do that;
y=fscanf(fileID,'%g\n',[22;23]);
degree located 22nd and 23nd column,
you undestand that ı tried to do could anyone help me thanks

 Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Mayo de 2020
y = fscanf(fileID,'%*21c%g\n');

3 comentarios

Ugur Sahin
Ugur Sahin el 17 de Mayo de 2020
thank you so much ı have a quastion more. If ı want to scan first colon to 21st how can i do ?
Walter Roberson
Walter Roberson el 17 de Mayo de 2020
would the colon be in a fixed position?
'%*18c%3c%*[^\n]\n'
this will include the trailing space in column 21. If you are after the number without the space (2 columns) then use %f instead of %3c
Ugur Sahin
Ugur Sahin el 19 de Mayo de 2020
thanks this is so useful for me.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Entering Commands en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 10 de Mayo de 2020

Comentada:

el 19 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by