save obj creates a large mat files, disagrees with whos
2 次查看(过去 30 天)
显示 更早的评论
Hello
I have a class Node with 3 properties: index , coord, and orientation; or any class.
classdef Node
properties
idx; %index
coord; %coordinates
ori; %origin , rotation, whatever
end
methods
function obj=Node(id,coo,or) %simplest construtor ever
obj.idx=id;
obj.coord=coo;
obj.ori=or;
end
end
end
when i run this for loop:
clear nodes
for i=1:1000
nodes(i)=Node(i,[i i i ] , [0 0 0 ]);
end
I got a vector of obj Node , and "whos nodes" gives me
Name Size Bytes Class Attributes
nodes 1x1000 56000 Node
with 7 doubles * 8 bytes/double * 1000 = 56000 Bytes
But save produces an extremendly larger file
save 'nodes.mat' nodes;
ls -la nodes.mat = 1179578 bytes ~1.2M
I would have expected the mat file to be a big larger than what is reported by whos ( size, m ,n , address, class name, etc ) but not 20 times larger
How could it be ?
Thanks
Julia
2 个评论
per isakson
2019-10-30
编辑:per isakson
2019-10-31
With R2018b
save( 'nodes1.mat', 'nodes', '-v7' );
save( 'nodes2.mat', 'nodes', '-v7.3' );
The first gives a 22KB file (less than half of what whos reports) and the second 1.2MB
'How could it be?' '-v7.3' produces an involved HDF5 file. HDF5 shines when it comes to large numerical arrays and "signals".
回答(1 个)
per isakson
2019-10-31
编辑:per isakson
2019-10-31
"Once I have reached the 2GB data size format v7 will no longer work." ???
Doc on save v7 says: 2^31 bytes per variable
Experiment (R2018b)
%%
a1 = rand(1e6,1e3); % rand to avoid dramatic compression
a01 = a1(1:1e5,:);
a02 = a1(1e5:2e5,:);
a03 = a1(2e5:3e5,:);
a04 = a1(3e5:4e5,:);
a05 = a1(4e5:5e5,:);
a06 = a1(5e5:6e5,:);
whos
Name Size Bytes Class Attributes
a01 100000x1000 800000000 double
a02 100001x1000 800008000 double
a03 100001x1000 800008000 double
a04 100001x1000 800008000 double
a05 100001x1000 800008000 double
a06 100001x1000 800008000 double
save( '-regexp', 'a0\d', '-v7' );
produces a 4.5GB mat-file
"industrial enviroment" You might want to discuss your problem with MathWorks. I don't know the limits of v7 and you don't want to find out when it is too late.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!