Fast method of data storage / retrieval?

조회 수: 4 (최근 30일)
Darin McCoy
Darin McCoy 2011년 8월 2일
Hi,
I have a set of file paths that i currently store in cell format every day. For example, Files is a 3x1 cell that contains paths in C:\genscripts
Files =
'C:\genscripts\AT-735-PD_T4P00252.txt'
'C:\genscripts\AT-740-CANcase_projects.txt'
'C:\genscripts\AT-740-PD2_T4R00262.txt'
This Files result is stored in a MAT file with the command
save('myfiles.mat','Files')
and this result is continually repeated (to have a fast and up to date directory of what files are). Is there any way to do this faster?

답변 (2개)

Oleg Komarov
Oleg Komarov 2011년 8월 2일
Saving .mat files in '-v6' won't compress them and you will save time.
EDIT
save('myfiles.mat','Files','-v6')
  댓글 수: 2
Darin McCoy
Darin McCoy 2011년 8월 2일
I should have clarified - i would like to save time when loading these files. Is a MAT file the best choice? Are cells the best choice for storing?
Oleg Komarov
Oleg Komarov 2011년 8월 2일
If you save with in '-v6' format when you load you will save time because no decompression is performed.
Mat file is a good choice. The size of the file matters.

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


Walter Roberson
Walter Roberson 2011년 8월 2일
Saving as text might be even faster.
MyFiles = regexp(fread('myfiles.txt'), '\n', 'split');
or
fid = fopen('myfiles.txt','rt');
MyFiles = textscan(fid,'%[^\n]');
fclose(fid);
or a number of other variations.
What you do might depend in part upon whether your file names are restricted to ASCII, or to UTF-16BE, or are general UTF-8 .

카테고리

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