|
1 | 1 | %% export_WBC.m
|
2 | 2 | %
|
3 | 3 | % Export Simulink models to a previous supported version. Currently,
|
4 |
| -% the default version is MATLAB 2017b. IF YOU OWE A MATLAB VERSION GREATER |
5 |
| -% THAN 2017B, REMEMBER TO EXPORT ALL MODELS TO THE DEFAULT SUPPORTED |
| 4 | +% the default version is MATLAB 2019b. IF YOU OWE A MATLAB VERSION GREATER |
| 5 | +% THAN 2019B, REMEMBER TO EXPORT ALL MODELS TO THE DEFAULT SUPPORTED |
6 | 6 | % VERSION BEFORE PUBLISHING ANY MODIFICATIONS, OTHERWISE OTHER USERS MAY
|
7 | 7 | % NOT BE ABLE TO USE THE MODELS!
|
8 | 8 | %
|
|
12 | 12 |
|
13 | 13 | fprintf('\nwhole-body-controllers\n');
|
14 | 14 | fprintf('\nExport project to a previous Matlab version\n');
|
| 15 | +fprintf('\nWBC Default version: R2019b\n'); |
15 | 16 | fprintf('\nOldest supported version: R2014a\n');
|
16 | 17 |
|
17 | 18 | fprintf('\n######################################################\n');
|
|
21 | 22 | fprintf('\nmay still not work properly.\n');
|
22 | 23 | fprintf('\n######################################################\n\n');
|
23 | 24 |
|
24 |
| -% list of all simulink models (in this repo only .mdl are allowed) in the project |
| 25 | +% list of all simulink mdl and slx in the project |
25 | 26 | mdlList = dir('../**/*.mdl');
|
| 27 | +slxList = dir('../**/*.slx'); |
26 | 28 |
|
27 | 29 | % matlab version to which export all models
|
28 | 30 | matlabVer = input('Specify the Matlab version to export models (format: R20XXx) ','s');
|
29 | 31 |
|
30 | 32 | %% Verify matlab version
|
31 | 33 |
|
32 |
| -% latest version: R2018a |
33 |
| -matlabVer_list = {'R2014a','R2014b','R2015a','R2015b','R2016a','R2016b','R2017a','R2017b','R2018a'}; |
| 34 | +% latest version: R2019b |
| 35 | +matlabVer_list = {'R2014a','R2014b','R2015a','R2015b','R2016a','R2016b','R2017a','R2017b','R2018a','R2018b','R2019a','R2019b'}; |
34 | 36 |
|
35 | 37 | % associated Simulink version
|
36 |
| -simulinkVer_number = {'8.3','8.4','8.5','8.6','8.7','8.8','8.9','9.0','9.1'}; |
| 38 | +simulinkVer_number = {'8.3','8.4','8.5','8.6','8.7','8.8','8.9','9.0','9.1','9.2','9.3','10.0'}; |
37 | 39 |
|
38 | 40 | % installed Simulink version
|
39 | 41 | currentSimulinkVer = ver('Simulink');
|
|
65 | 67 | end
|
66 | 68 |
|
67 | 69 | %% Load the Simulink models and export to previous versions
|
68 |
| -mdlVer_list = {'R2014A_MDL','R2014B_MDL','R2015A_MDL','R2015B_MDL','R2016A_MDL','R2016B_MDL','R2017A_MDL','R2017B_MDL','R2018A_MDL'}; |
| 70 | +mdlVer_list = {'R2014A_MDL','R2014B_MDL','R2015A_MDL','R2015B_MDL','R2016A_MDL','R2016B_MDL','R2017A_MDL','R2017B_MDL','R2018A_MDL','R2018B_MDL','R2019A_MDL','R2019B_MDL'}; |
| 71 | +slxVer_list = {'R2014A_SLX','R2014B_SLX','R2015A_SLX','R2015B_SLX','R2016A_SLX','R2016B_SLX','R2017A_SLX','R2017B_SLX','R2018A_SLX','R2018B_SLX','R2019A_SLX','R2019B_SLX'}; |
69 | 72 |
|
70 | 73 | % close all open models (if there is any)
|
71 | 74 | close_system('',0)
|
72 | 75 |
|
73 | 76 | for k = 1:length(mdlList)
|
74 | 77 |
|
75 |
| - fprintf(['\nLOADED MODEL: ' mdlList(k).name '\n']); |
| 78 | + fprintf(['\nLOADED MDL FILE: ' mdlList(k).name '\n']); |
76 | 79 | open_system([mdlList(k).folder,'/',mdlList(k).name],'loadonly');
|
77 | 80 |
|
78 | 81 | % save the model in a temporary copy. Then, export the copy into
|
|
97 | 100 | % delete the temporary model
|
98 | 101 | delete([mdlList(k).folder,'/',mdlList(k).name(1:end-4),'_temp.mdl'])
|
99 | 102 | end
|
| 103 | +for k = 1:length(slxList) |
| 104 | + |
| 105 | + fprintf(['\nLOADED SLX FILE: ' slxList(k).name '\n']); |
| 106 | + open_system([slxList(k).folder,'/',slxList(k).name],'loadonly'); |
| 107 | + |
| 108 | + % save the model in a temporary copy. Then, export the copy into |
| 109 | + % the previous version, by overwriting the original model |
| 110 | + fprintf('\n saving a temporary copy of the model \n\n'); |
| 111 | + save_system([slxList(k).folder,'/',slxList(k).name], [slxList(k).folder,'/',slxList(k).name(1:end-4),'_temp.slx']); |
| 112 | + close_system([slxList(k).folder,'/',slxList(k).name],0); |
| 113 | + open_system([slxList(k).folder,'/',slxList(k).name(1:end-4),'_temp.slx'],'loadonly'); |
| 114 | + |
| 115 | + % do not export if simulink models are already at the required version |
| 116 | + if str2double(simulinkVer_number{matlabVer_found}) == str2double(currentSimulinkVer.Version) |
| 117 | + |
| 118 | + fprintf('\n model is already at the required version. \n'); |
| 119 | + else |
| 120 | + save_system([slxList(k).folder,'/',slxList(k).name(1:end-4),'_temp.slx'], [slxList(k).folder,'/',slxList(k).name], 'ExportToVersion', slxVer_list{matlabVer_found}); |
| 121 | + end |
| 122 | + |
| 123 | + % closing the temporary model |
| 124 | + fprintf('\n closing the model \n'); |
| 125 | + close_system([slxList(k).folder,'/',slxList(k).name(1:end-4),'_temp.slx']); |
| 126 | + |
| 127 | + % delete the temporary model |
| 128 | + delete([slxList(k).folder,'/',slxList(k).name(1:end-4),'_temp.slx']) |
| 129 | +end |
100 | 130 |
|
101 | 131 | fprintf('\nDone.\n');
|
0 commit comments