function [] = LatexCodeMatrix(A,formating,fileID)

%

[rows,columns] = size(A);

fprintf(fileID,'\\begin{array}{');
for i = 1:columns
    fprintf(fileID,'r');
end
fprintf(fileID,'}\n');
for i = 1:rows
    for j = 1:columns
        fprintf(fileID,formating,A(i,j));
        if j < columns
            fprintf(fileID,' & ');
        end
        if (j == columns) && (i < rows)
            fprintf(fileID,' \\\\\n');
        end
        if (j == columns) && (i == rows)
            fprintf(fileID,' \n');
        end
    end
end
fprintf(fileID,'\\end{array}');

end