Changeset 7301


Ignore:
Timestamp:
02/03/11 15:53:16 (14 years ago)
Author:
Mathieu Morlighem
Message:

Was not a fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/utils/Model/loadmodel.m

    r7291 r7301  
    1616        error(['loadmodel error message: file ' path ' does not exist']);
    1717end
    18 %check that the file is readable
    19 [stat,mess]=fileattrib(path);
    20 if( stat==0 | mess.UserRead~=1),
    21         %error(['loadmodel error message: file ' path ' is not readable (permission denied).']);
    22 end
    23 %check number of variables
    24 if length(whos('-file',path))>1,
    25         error(['loadmodel error message: file ' path ' contains several variables. Only one model should be present.']);
    26 end
    2718
    2819try,
    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]);
    3327       
    3428        %now, transform md into a new model
    3529        if ~strcmpi(class(md),'model'),
    36                 md2=model;
    37                 md2=structtomodel(md2,md);
     30                md2=structtomodel(model,md);
    3831                md=md2;
    3932                clear md2;
     
    4235                varargout{1}=md;
    4336        else
    44                 assignin('caller',fieldname,md);
     37                assignin('caller',name,md);
    4538        end
    4639catch me
Note: See TracChangeset for help on using the changeset viewer.