.mat file size keeping it small on compiling

조회 수: 2 (최근 30일)
In-chan Kim
In-chan Kim 2020년 6월 15일
댓글: Walter Roberson 2020년 6월 29일
Hi,
I'm compiling some .mat files and saving it, but the overall saved data is bigger than the sumer of the files being used.
Is this normal? Is there a way to keep it down?
The compiled file is 470MB, and the sum of the files being used is about 125MB
form=1; %make sure to also change the formulation number under filename
scenarios = 5;
Nscen = numel(scenarios);
IDsets = 1:500:3001;
NID = numel(IDsets);
filedir = 'Outputs';
indvoutputagg = cell(NID,1); % preallocate
indvoutputcomp={};
for i=1:Nscen
for k = 1:NID
filename = sprintf('Form1_Scenario%d_ID%ds_indvoutputagg.mat',scenarios(i),IDsets(k));
indvoutputagg{k,:} = importdata(fullfile(filedir,filename)); % allocate using indexing
% Make it into one big table
indvoutputcomp(1+size(indvoutputcomp,1):size(indvoutputcomp,1)+size(indvoutputagg{k,1},1),:)=indvoutputagg{k};
end
save(['Outputs/Form' num2str(form) '_Scenario' num2str(scenarios(i)) '_indvoutputagg.mat'],'indvoutputcomp')
end
  댓글 수: 5
In-chan Kim
In-chan Kim 2020년 6월 29일
Is there something I can do to make it smaller?
Walter Roberson
Walter Roberson 2020년 6월 29일
I recommend against using importdata() -- too much overhead for the cases where the output is well defined, and too uncertain about what it will return for the other cases. You are reading in a .mat file: just load() it .
The .mat files you are reading in: do they all have exactly the same variable names? Would the variable names also happen to be in exactly the same order in each file? If they do not have exactly the same variable names, then are the variable names self-identifying as to which file they came from? For example if all of the 501 variables mention 501 at a particular location in their name, then if we threw all the loaded variables into the same structure, we could figure out afterwards which file they came from.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by