Home > vbmeg > functions > common > utility > vb_struct2mscript.m

vb_struct2mscript

PURPOSE ^

Convert struct to file.

SYNOPSIS ^

function vb_struct2mscript(s, mfile, struct_name)

DESCRIPTION ^

 Convert struct to file.
 [USAGE]
    vb_struct2mscript(s, mfile [,struct_name])
 [IN]
              s : <<struct>> structure.
       filename : <<string>> mfile name.
    struct_name : (opt) <<string>> struct name. 
                    When 'inputname' function cannot detect the struct name.
                    e.g.: vb_struct2_mscript(structarray{1}, mfile)
                    Specify the 3rd argument.
                    vb_struct2mscript(structarray{1}, mfile, 'structarray{1}');
 [OUT]
    none

 [See also]
    vb_struct2executable_str

 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 vb_struct2mscript(s, mfile, struct_name)
0002 % Convert struct to file.
0003 % [USAGE]
0004 %    vb_struct2mscript(s, mfile [,struct_name])
0005 % [IN]
0006 %              s : <<struct>> structure.
0007 %       filename : <<string>> mfile name.
0008 %    struct_name : (opt) <<string>> struct name.
0009 %                    When 'inputname' function cannot detect the struct name.
0010 %                    e.g.: vb_struct2_mscript(structarray{1}, mfile)
0011 %                    Specify the 3rd argument.
0012 %                    vb_struct2mscript(structarray{1}, mfile, 'structarray{1}');
0013 % [OUT]
0014 %    none
0015 %
0016 % [See also]
0017 %    vb_struct2executable_str
0018 %
0019 % Copyright (C) 2011, ATR All Rights Reserved.
0020 % License : New BSD License(see VBMEG_LICENSE.txt)
0021 
0022 %
0023 % --- Previous check
0024 %
0025 if ~exist('s', 'var')
0026     error('Structure is not specified.');
0027 end
0028 
0029 %
0030 % --- Main Procedure
0031 %
0032 if ~exist('struct_name', 'var')
0033     struct_name = inputname(1);
0034 end
0035 if isempty(struct_name)
0036     error('struct_name should be specified at 3rd argument.');
0037 end
0038 dlmwrite(mfile, vb_struct2executable_str(s, struct_name), 'delimiter', '');

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005