Home > marsbar > savestruct.m

savestruct

PURPOSE ^

saves data in structure as variables in .mat file

SYNOPSIS ^

function savestruct(varargin)

DESCRIPTION ^

 saves data in structure as variables in .mat file
 FORMAT savestruct(matname, struct) or
 FORMAT savestruct(struct, matname)  

 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function savestruct(varargin)
0002 % saves data in structure as variables in .mat file
0003 % FORMAT savestruct(matname, struct) or
0004 % FORMAT savestruct(struct, matname)
0005 %
0006 % $Id$
0007   
0008 if nargin ~= 2
0009   error('Need matfile name and structure (only)');
0010 end
0011 if isstruct(varargin{1}), varargin = varargin([2 1]); end
0012 varargin{3} = fieldnames(varargin{2});
0013 if any(ismember(varargin{3}, {'wombat_tongue'}))
0014   error('Whoops, unexpected use of wombat_tongue');
0015 end
0016 for wombat_tongue = 1:length(varargin{3})
0017   eval([varargin{3}{wombat_tongue} ' = varargin{2}.' varargin{3}{wombat_tongue} ...
0018     ';']);
0019 end
0020 save(varargin{1}, varargin{3}{:});
0021 return

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019