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

3 views (last 30 days)
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.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 19 Jan 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').

More Answers (0)

Products


Release

R2006b

Community Treasure Hunt

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

Start Hunting!