Retrieving names of all Configuration sets in the base workspace

7 vues (au cours des 30 derniers jours)
Stu
Stu le 24 Juil 2014
Réponse apportée : Stu le 29 Juil 2014
Hi, I currently have 2 configuration sets stored in my Base workspace, which are being referenced by a model and reference models. By using the command
myConfigObjNames = getConfigSets(gcs);
I can retrieve the name of the configuration reference, rather than the names of the configuration set. I am hoping to retrieve an array of strings (each configset in base workspace) so that I can produce a command like
comargs = 'Configurationsets.Mat ';
numargs = size(myConfigObjNames,1);
for n = 1 :numargs
comargs = fullfile(comargs,', ',myConfigObjNames[n]);
end
save(comargs);
The above is an example and probably buggy.
but I don't know how to pull the data from the base workspace to fill the original array any ideas?

Réponse acceptée

Stu
Stu le 29 Juil 2014
This has been solved now, for anyone with a similar problem
% Find all config sets
myvars = whos;
cslist = {};
%for length of veriable list check veriable class,
%if equal to configuration set append to cslist
for i=1:length(myvars)
if ~isempty(regexp(myvars(i).class,'Simulink\.ConfigSet','once'))
cslist{end+1}=myvars(i).name; %#ok
end
end
%user interface to select folder
Pathname = uigetdir(' ', 'Choose a Folder to write to');
%build command
Pathname = fullfile(Pathname, 'ConfigurationSets.mat');
comargs = sprintf('save %s', Pathname);
%Add all arguments to the command
numargs = size(cslist,2);
for n = 1 :numargs
comargs = sprintf('%s %s',comargs,cslist{n});
end
%Run the command
eval(comargs);
%Clean up
clear cslist i n myvars Pathname comargs numargs

Plus de réponses (0)

Catégories

En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by