Home > functions > common > utility > vb_fsave.m

vb_fsave

PURPOSE ^

Save variables into mat-file by MATLAB version 6 format. (Overwrite mode)

SYNOPSIS ^

function [result] = vb_fsave(varargin)

DESCRIPTION ^

 Save variables into mat-file by MATLAB version 6 format. (Overwrite mode)
   vb_fsave(filename, 'V', 'XX', ... )
 [IN]  varargin : variable name string. (varargin{1} = filename)
 [OUT] result   : SUCCESS or FAILURE;
 
 Example:
  vb_fsave(filename, 'V', 'XX', ... )
 Memo:
  if specified file already exists, the file will be overwritten.
   @see vbmeg.m where "vbmeg_saving_version" is set
   @see vb_save.m
 History:
   ****-**-** (****) initial version
   2009-07-06 (Sako) changed specification of the default version

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [result] = vb_fsave(varargin)
0002 % Save variables into mat-file by MATLAB version 6 format. (Overwrite mode)
0003 %   vb_fsave(filename, 'V', 'XX', ... )
0004 % [IN]  varargin : variable name string. (varargin{1} = filename)
0005 % [OUT] result   : SUCCESS or FAILURE;
0006 %
0007 % Example:
0008 %  vb_fsave(filename, 'V', 'XX', ... )
0009 % Memo:
0010 %  if specified file already exists, the file will be overwritten.
0011 %   @see vbmeg.m where "vbmeg_saving_version" is set
0012 %   @see vb_save.m
0013 % History:
0014 %   ****-**-** (****) initial version
0015 %   2009-07-06 (Sako) changed specification of the default version
0016 %
0017 % Copyright (C) 2011, ATR All Rights Reserved.
0018 % License : New BSD License(see VBMEG_LICENSE.txt)
0019 
0020 global vbmeg_saving_version
0021 
0022 result = FAILURE;
0023 
0024 if nargin <= 1, return; end;
0025 
0026 % extension change to '.mat'
0027 file_name = varargin{1};
0028 
0029 % [PATH, NAME, EXT] = fileparts(file_name);
0030 [PATH, NAME, EXT] = vb_get_file_parts(file_name);
0031 EXT = '.mat';
0032 file_name = fullfile(PATH, [NAME, EXT]);
0033 
0034 num_variable = length(varargin)-1;
0035 
0036 % set save option
0037 % if vb_matlab_version >= 7
0038 %     compatible_option = '-v6';
0039 % else
0040 %     compatible_option = '';
0041 % end
0042 compatible_option = vbmeg_saving_version;
0043 
0044 % make save command string
0045 save_command = ...
0046             ['save ' file_name, ' ', ...
0047                      compatible_option];
0048 for k=1:num_variable
0049     save_command = [save_command ' ' varargin{k+1}];
0050 end
0051 
0052 % execute save command on caller workspace.
0053 evalin('caller', save_command);
0054 
0055 result = SUCCESS;

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005