Borrar filtros
Borrar filtros

Why fscanf return strange character I do not see in notepad?

1 visualización (últimos 30 días)
Hi all,
I have several txt files that look fine in Notepad, but they are full of strange characters from fscanf and I'm wondering why it occurs.
Here my code:
TxtFid=fopen([TxtPath TxtFile]);
Txt=fscanf(TxtFid,'%c');
Here how the a part of the file looks like in notepad:
25,33 de / from 0 à / to 28,6
Here how the same part looks from fscanf:
≤ 25,33 de / from 0 à / to 28,6
Why does it occur? For the coding? May trying several codings solve the problem?
I tried yo change the coding as the following:
TxtFid=fopen([TxtPath TxtFile],[],[],'windows-847');
but Matlab returns:
Error using fopen
Invalid permission.
How may I solve the problem?
Thanks
Cheers
  3 comentarios
pietro
pietro el 9 de Mayo de 2016
From Matlab documentation:
fileID = fopen(filename,permission,machinefmt,encodingIn)
For this reason, I used the function as the following:
TxtFid=fopen([TxtPath TxtFile],[],[],'windows-847');
Walter Roberson
Walter Roberson el 9 de Mayo de 2016
You need to provide valid entries there. Empty entries are not accepted.

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 6 de Mayo de 2016
Use fread() instead.
  1 comentario
pietro
pietro el 9 de Mayo de 2016
It worked. I just used fread in the following way:
Txt=fread(TxtFid);
Txt=char(Txt)';
Why is there so much difference among the two uses?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import and Export 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