Why does FREAD read my data incorrectly when using the 'char' format specification with MATLAB 7.3 (R2006b) on Linux?

3 visualizzazioni (ultimi 30 giorni)
When I use the following command on Windows with MATLAB 7.3 (R2006b):
a=fread(fopen('test'),64,'char')';
size(a)
I obtain
ans =
1 64
On Linux I obtain:
ans =
1 62
'schar' and 'uchar' format specification give me the same answer with FREAD on every platforms.

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 19 Gen 2010
'char' to FREAD means "read a character in the local codepage". The local codepage is different on Windows and Linux, so that is why there are different results between OSes. To read unsigned bytes and not characters, the correct precision specification is 'uint8' (which is the same as 'uchar').

Più risposte (0)

Prodotti


Release

R2006b

Community Treasure Hunt

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

Start Hunting!

Translated by