save obj creates a large mat files, disagrees with whos
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
per isakson
am 30 Okt. 2019
Bearbeitet: per isakson
am 31 Okt. 2019
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".
Antworten (1)
per isakson
am 31 Okt. 2019
Bearbeitet: per isakson
am 31 Okt. 2019
"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 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!