How to read 16-bit text with Matlab

12 visualizzazioni (ultimi 30 giorni)
Frank
Frank il 1 Mar 2016
Modificato: Les Beckham il 20 Mag 2022
I have an Agilent 34970A data logger with their BenchLink software. This puts out a .csv file that Excel reads with no trouble. But Matlab cannot import it because it's 16 bit text. The first two bytes are 0xFF 0xFE, then after that every text byte is followed by a NULL (0x00). I wrote a function to read it, but I was hoping for the ability to read it directly, without having to programmatically skip the NULLs.

Risposta accettata

Walter Roberson
Walter Roberson il 1 Mar 2016
MATLAB does not handle UTF-16LE files. You might wish to use the source code I posted in http://uk.mathworks.com/matlabcentral/answers/267176-read-and-seperate-csv-data#answer_209938 which reads csv files from any of the UTF-8 / UTF-16 / UTF-32 encodings
  9 Commenti
keldstefan
keldstefan il 20 Mag 2022
Very nice Walter ;)
Does anybody know how to deactivate the warning?
"Warning: The encoding 'XXXXXXX' is not supported.
See the documentation for FOPEN."
I am reading several hundreds of these files, I'd like to remove this output from the console...
Les Beckham
Les Beckham il 20 Mag 2022
Modificato: Les Beckham il 20 Mag 2022
To disable the warning, issue the following command after you receive that warning:
[msg, id] = lastwarn;
Then, disable the warning as follows:
warning('off', id)

Accedi per commentare.

Più risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by