ET_PDToolkit/PDToolkit/@PDSettings/load.m

32 lines
839 B
Matlab

function[obj] = load(obj, varargin)
%% Load settings from file
% this can be
% a) PDExperiment file (*_PDExp.mat)
% b) PDSettings file (*_PDSet.mat)
if nargin == 1
[fromfile fromdir]= uigetfile;
source = [fromdir filesep fromfile];
if (strfind(source,'_PDExp'))
exp_obj = load(source)
obj_tmp = exp_obj.e.settings;
if (strcmp(class(obj_tmp), 'PDSettings'))
obj = obj_tmp;
else
fields = fieldnames(obj_tmp);
for f = 1:length(fields)
obj.(fields{f}) = obj_tmp.(fields{f});
end
end
return
end
if (strfind(source, '_PDSet.mat'))
obj = load(source);
return
end
warning(sprintf('Could not load settings from file : %s', source));
end