0001 function vb_matfile_to_v6(inputfile, output_v6, output_org)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 if vb_matlab_version < 7
0028 error('This function should be executed in MATLAB version 7 or later. File not converted.');
0029 end
0030 if ~exist('inputfile', 'var')
0031 error('inputfile is a required parameter.');
0032 end
0033 if exist(inputfile, 'file') ~= 2
0034 error('inputfile not found.');
0035 end
0036
0037 if ~exist('output_v6', 'var'), output_v6 = ''; end
0038 if ~exist('output_org', 'var'), output_org = ''; end
0039 if isdir(output_org), output_org = fullfile(output_org, inputfile); end
0040
0041
0042
0043
0044 if isempty(output_v6), output_v6 = inputfile; end
0045
0046 if ~strcmp(output_v6, output_org) && ~isempty(output_org)
0047 do_copy = true;
0048 if exist(output_org, 'file') == 2
0049 res = questdlg([output_org ' is already exists. Overwrite?'], ...
0050 'Copy Original file', 'Yes', 'No', 'Yes');
0051 if strcmp(res, 'No'), do_copy = false; end
0052 end
0053 if do_copy
0054
0055 [result, msg, msg_id] = copyfile(inputfile, output_org);
0056
0057 if result == 0
0058 fprintf('XXX : original file copy was failed. output_org = %s\n', ...
0059 output_org);
0060 fprintf('XXX : conversion was terminated.\n');
0061 return;
0062 end
0063 fprintf('original file copy was succeeded.\n');
0064 else
0065 fprintf('original file copy was cancelled.\n');
0066 end
0067 end
0068
0069
0070 S = load(inputfile);
0071
0072 do_convert = true;
0073 if ~strcmp(inputfile, output_v6) && exist(output_v6, 'file') == 2
0074 res = questdlg([output_v6 ' is already exists. Overwrite?'], ...
0075 'Conversion', 'Yes', 'No', 'Yes');
0076 if strcmp(res, 'No'), do_convert = false; end
0077 end
0078
0079
0080 if do_convert
0081 save(output_v6, '-STRUCT', 'S', '-V6');
0082 fprintf('file conversion was succeeded.\n');
0083 else
0084 fprintf('file conversion was cancelled.\n');
0085 end