forked from Future-Power-Networks/Simplus-Grid-Tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArchive.m
49 lines (42 loc) · 1.13 KB
/
Archive.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
% the function will save a model in 2015a format under 'install' folder
%
% Author(s): Yitong Li, Yunjie Gu
%
% parameter:
% model = path/to/file/model.ext, in relative path to the
% current (working) path, and .ext is the extention name of the model,
% which is .slx by default if left empty
%
% usage:
% method(1)
% cd('path/to/file')
% simplus.archive('model')
% method(2)
% simplus.archive('path/to/file/model')
% method(3)
% simplus.archive('path/to/file/model.mdl')
function Archive(model)
current_path = pwd;
[file_path,file_name,file_ext] = fileparts(model);
if isempty(file_name)
return;
end
if isempty(file_ext)
file_ext = '.slx';
end
if ~isempty(file_path)
cd(file_path);
end
if ~isfile([file_name file_ext])
cd(current_path);
return;
end
if ~isfolder('install')
mkdir('install');
end
archive_path = fullfile(current_path,file_path,'Install',[file_name '_Archive' file_ext]);
load_system(file_name);
save_system(file_name,archive_path,'ExportToVersion','R2015A');
close_system(file_name);
cd(current_path);
end