function save_int3(fname,var);
% save_int3(fname, var) saves the variable var in a text-file.
% The format of the output is three-char-ascii with rows separated by
% newline.

% The ASC files were obtained with the following commands:
% save_int3('test_data.asc',256*(1+test_label')/2);
% save_int3('train_data.asc',256*(1+train_data')/2);
% save_int3('test_label.asc',test_label');
% save_int3('train_label.asc',train_label');

fid = fopen(fname,'wt');

[xS,yS] = size(var);

if nargin<2;
  error('Wrong number of parameters');
elseif nargin==2
  fmtstr='%f';
end;


for ii=1:xS;
  for jj=1:yS;
    fprintf(fid,'%03.0f ',round(var(ii,jj)));
  end;
  fprintf(fid,'\n');
end;
