Effacer les filtres
Effacer les filtres

How to save variables as 16-bit signed integers?

4 vues (au cours des 30 derniers jours)
Agustin
Agustin le 27 Avr 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.

Réponses (0)

Catégories

En savoir plus sur Low-Level File I/O dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by