Changeset 12648


Ignore:
Timestamp:
07/18/12 10:23:24 (13 years ago)
Author:
Mathieu Morlighem
Message:

can now save and load matlab objects that are not structures

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/organizer.m

    r12365 r12648  
    6969                 end
    7070                 %}}}
     71                 function md=load(org,string),% {{{
     72
     73                         %Get model path
     74                         if ~ischar(string), error('argument provided is not a string'); end
     75                         path=[org.repository '/' org.prefix string];
     76
     77                         %figure out if the model is there
     78                         if exist(path,'file'),
     79                                 struc=load(path,'-mat');
     80                                 name=char(fieldnames(struc));
     81                                 md=struc.(name);
     82                                 if nargout,
     83                                         varargout{1}=md;
     84                                 end
     85                         else
     86                                 error(['Could not find ' path ]);
     87                         end
     88                 end%}}}
    7189                 function md=loadmodel(org,string),% {{{
    7290
     
    7694
    7795                         %figure out if the model is there, otherwise, we have to use the default path supplied by user.
    78                          if exist(path,'file'),
     96                         if exist(path,'file') | exist([path '.mat'],'file'),
    7997                                 md=loadmodel(path);
    8098                                 return;
     
    139157                         
    140158                         %check that md is a model
    141                          if ~isa(md,'model'),       error('savemodel error message: third argument is not a model'); end
     159                         if ~isa(md,'model'), warning('third argument is not a model'); end
    142160                         if (org.currentstep>length(org.steps)), error(['organizer error message: element with id ' num2str(org.currentstep) ' not found']); end
    143161
Note: See TracChangeset for help on using the changeset viewer.