2 % Save arrays into .plt format
3 % save_plt(filename, arrays... )
7 function [varargout]=save_plt(filename, varargin)
9 %total size calculating
10 total_size = size(varargin{1}.arr, 1)*size(varargin{1}.arr, 2)*size(varargin{1}.arr, 3);
12 %adding all arrays to the 1 array
14 %reshape first array to the 1d array and add to the total array
15 total_array = reshape(permute(varargin{1}.arr, [3,2,1]), [total_size, 1]);
17 % creating output format
18 format_string =
'%e\t';
20 %reshape others arrays to the 1d array and add to the total array
21 total_array = [total_array, reshape(permute(varargin{it}.arr, [3,2,1]), [total_size, 1])];
22 n_of_vars = n_of_vars + 1;
23 format_string = [format_string, '%e\t'];
26 format_string = [format_string, '\n'];
29 total_array (find(~isfinite(total_array)))=1e-22;
31 fid = fopen(filename,
'w');
36 for comment = varargin{it}.comments
37 fprintf(fid,
'%s\n', comment{1});
43 % %trying to write comments,
if exists
44 % fprintf(fid,
'%s\n', varargin{it}.comments);
52 fprintf(fid, 'VARIABLES = ');
55 %trying to write var-name, if exists
56 fprintf(fid, '"%s", ', varargin{it}.name); % ...name{1}
58 fprintf(fid,
'"func.", ');
61 fprintf(fid,
'\nZONE T="..." I=%d, J=%d, K=%d\n', size(varargin{1}.arr, 3), size(varargin{1}.arr, 2), size(varargin{1}.arr, 1));
63 fprintf(fid, format_string, total_array
');