annotate matlab/db/dbsave.m @ 37:89688ebc447f
tip
Deprecating this repository.
author |
samer |
date |
Mon, 05 Jan 2015 17:42:03 +0000 |
parents |
0dd31a8c66bd |
children |
|
rev |
line source |
samer@0
|
1 function locator=dbsave(x)
|
samer@0
|
2 % dbsave - Save object to MatBase using given name
|
samer@0
|
3 %
|
samer@0
|
4 % dbsave :: A -> action locator(A).
|
samer@0
|
5
|
samer@0
|
6 % SA: 2008-05-20 - no longer saving file name in mat file
|
samer@0
|
7
|
samer@0
|
8 dt=clock;
|
samer@0
|
9 [root,host]=dbroot;
|
samer@0
|
10 dir=[host dirname(dt)]; % makes up a directory name based on the date.
|
samer@0
|
11 if ~exist(fullfile(root,dir),'dir')
|
samer@0
|
12 [rc,msg]=mkdir(strrep(root,'~',getenv('HOME')),dir);
|
samer@0
|
13 end
|
samer@0
|
14
|
samer@0
|
15 fn=uniquefile(dt,root,dir,'m%s.mat'); % make up a filename
|
samer@0
|
16 save(fullfile(root,fn),'x');
|
samer@0
|
17 locator=[removeext(fn),'|x'];
|
samer@0
|
18
|
samer@0
|
19 % make up directory name based on the year and month
|
samer@0
|
20 function dir=dirname(dt)
|
samer@0
|
21 dir=sprintf('d%s%s',datestr(dt,'yy'),datestr(dt,'mm'));
|
samer@0
|
22
|
samer@0
|
23
|