How to save variables as 16-bit signed integers?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (0)
Voir également
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!