1 |
gforget |
1.1 |
function []=write2file(fileOut,fldIn,varargin); |
2 |
|
|
%purpose: write array to binary file |
3 |
|
|
% |
4 |
|
|
%inputs: fileOut is the file name |
5 |
|
|
% fldIn is the array to write to disk |
6 |
|
|
%(optional) prec is the file precision (32, by default, or 64) |
7 |
|
|
|
8 |
|
|
if nargin>2; prec=varargin{1}; else; prec=32; end; |
9 |
|
|
|
10 |
|
|
if ~ischar(fldIn); |
11 |
|
|
fid=fopen(fileOut,'w','b'); tmp1=fldIn; tmp1(isnan(tmp1))=0; fwrite(fid,tmp1,['float' num2str(prec)]); fclose(fid); |
12 |
|
|
else; |
13 |
|
|
fid=fopen(fileOut,'wt'); fwrite(fid,fldIn); fclose(fid); |
14 |
|
|
end; |
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|