Changeset 7301
- Timestamp:
- 02/03/11 15:53:16 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/utils/Model/loadmodel.m
r7291 r7301 16 16 error(['loadmodel error message: file ' path ' does not exist']); 17 17 end 18 %check that the file is readable19 [stat,mess]=fileattrib(path);20 if( stat==0 | mess.UserRead~=1),21 %error(['loadmodel error message: file ' path ' is not readable (permission denied).']);22 end23 %check number of variables24 if length(whos('-file',path))>1,25 error(['loadmodel error message: file ' path ' contains several variables. Only one model should be present.']);26 end27 18 28 19 try, 29 %recover model and name it md 30 struc=struct(load(path,'-mat')); 31 fieldname=char(fieldnames(struc)); 32 md=eval(['struc.' fieldname]); 20 %recover model on file and name it md 21 struc=load(path,'-mat'); 22 name=char(fieldnames(struc)); 23 if size(name,1)>1, 24 error(['loadmodel error message: file ' path ' contains several variables. Only one model should be present.']); 25 end 26 md=eval(['struc.' name]); 33 27 34 28 %now, transform md into a new model 35 29 if ~strcmpi(class(md),'model'), 36 md2=model; 37 md2=structtomodel(md2,md); 30 md2=structtomodel(model,md); 38 31 md=md2; 39 32 clear md2; … … 42 35 varargout{1}=md; 43 36 else 44 assignin('caller', fieldname,md);37 assignin('caller',name,md); 45 38 end 46 39 catch me
Note:
See TracChangeset
for help on using the changeset viewer.