fid = fopen('/home/cflin/refs/round_corner_vers_idx5.txt', 'wt');
mat = tot_rc_idx;
for i = 1:size(mat, 1)
    fprintf(fid, '%d\t', mat(i,:));
    fprintf(fid, '\n');
end
fclose(fid);

%
% write DBC

fid = fopen('NNew_Data/DBC.txt', 'wt');
mat = the_gs_P;
for i = 1:size(mat, 1)
    fprintf(fid, '%f\t', mat(i,:));
    fprintf(fid, '\n');
end

mat = the_norm;
for i = 1:size(mat, 1)
    fprintf(fid, '%f\t', mat(i,:));
    fprintf(fid, '\n');
end

mat = the_w;
for i = 1:size(mat, 1)
    fprintf(fid, '%f\t', mat(i,:));
    fprintf(fid, '\n');
end

fclose(fid);

%
% write refs

the_file='/home/cflin/refs/';
for i_iter=[1 3 5 6]
   eval(['load' ' NNew_Sample/Piston28/refs' num2str(i_iter) '.mat ']);
    fid = fopen([the_file 'vers' num2str(i_iter) '.txt'], 'wt');
    writeMat(tot_V,fid);
    fid = fopen([the_file 'u' num2str(i_iter) '.txt'], 'wt');
    writeMat(tot_u,fid);
    fid = fopen([the_file 's' num2str(i_iter) '.txt'], 'wt');
    writeMat(tot_s,fid);
end

%

function writeMat(mat,fid)
    for i = 1:size(mat, 1)
        fprintf(fid, '%f\t', mat(i,:));
        fprintf(fid, '\n');
    end
    fclose(fid); 
end