How to save variables as 16-bit signed integers?

5 visualizaciones (últimos 30 días)
Agustin
Agustin el 27 de Abr. de 2017
Hi! I have a dct_blk array and I need to save it as a 16-bit signed integers. I did the following:
A = dct_blk';
fileID = fopen('img03y.dq','w');
fwrite(fileID,A,'integer*2');
fclose(fileID);
I transponse dct_blk because I need to store it in raster order from left-to-right and moving from top-to-bottom. But when I read my saved binary with the following code
fileID = fopen('img03y.dq');
B = fread(fileID,[N M],'uint16');
B = B';
I'm not getting the same values as dct_blk. I'm getting large numbers where the negative values supposed to be. What can I be doing wrong? Any help will be greatly appreciated.
Thank you.

Respuestas (0)

Categorías

Más información sobre Low-Level File I/O en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by