我有一个名为" Shanto"的三维矩阵。大小(232,232,3052)。
我想对内存进行映射,并使用以下命令:
fileID = fopen('Shanto.dat','w');
fwrite(fileID, Shanto, 'single');
fclose(fileID)
m = memmapfile('Shanto.dat')
然而,当我尝试访问m.Data时,我得到一个657083392 x 1 uint8数组。
如何使其保留原始矩阵的(232,232,3052)形状?
谢谢,
本
答案 0 :(得分:1)
加载.dat
文件时,您可以指定形状/格式(实际默认为uint8)。
您还需要使用fwrite指定正确的数据格式:
fileID = fopen('Shanto.dat','w');
fwrite(fileID, Shanto, 'uint8'); %// Instead of 'single' as before.
fclose(fileID)
m = memmapfile('Shanto.dat','Format',{'uint8',[232 232 3052],'MyFancyName'})
然后,您可以使用m.Data.MyFancyName
更多信息here