function print_mat(fid,text,matrix);
fprintf(fid,'\n %s \n\n',text);
column=size(matrix,2);
form='';
for i=1:column
    form=[form,'%-13.4e'];
    %form=[form,'%g '];
end
form=[form,'\n'];
% fprintf works column oriented => printing the transpose of the matrix
fprintf(fid,form,full(matrix'));