1 % Save arrays into .plt format
2 % save_plt(filename, arrays... )
4 % See also: save_picture
6 function [varargout]=save_plt(filename, varargin)
8 %total size calculating
9 total_size = size(varargin{1}.arr, 1)*size(varargin{1}.arr, 2)*size(varargin{1}.arr, 3);
11 %adding all arrays to the 1 array
13 %reshape first array to the 1d array and add to the total array
14 total_array = reshape(permute(varargin{1}.arr, [3,2,1]), [total_size, 1]);
16 % creating output format
17 format_string =
'%e\t';
19 %reshape others arrays to the 1d array and add to the total array
20 total_array = [total_array, reshape(permute(varargin{it}.arr, [3,2,1]), [total_size, 1])];
21 n_of_vars = n_of_vars + 1;
22 format_string = [format_string, '%e\t'];
25 format_string = [format_string, '\n'];
28 total_array (find(~isfinite(total_array)))=1e-22;
30 fid = fopen(filename,
'w');
35 for comment = varargin{it}.comments
36 fprintf(fid,
'%s\n', comment{1});
42 % %trying to write comments,
if exists
43 % fprintf(fid,
'%s\n', varargin{it}.comments);
51 fprintf(fid, 'VARIABLES = ');
54 %trying to write var-name, if exists
55 fprintf(fid, '"%s", ', varargin{it}.name); % ...name{1}
57 fprintf(fid,
'"func.", ');
60 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));
62 fprintf(fid, format_string, total_array
');