I have a TableForm as follows:
cosine[r_, theta_] := Sqrt[2 r^2 (1 - Cos[theta/360 * 2*Pi])];
rows = Range[1000, 10000, 1000];
cols = Prepend[Range[.5, 2, .5], ""];
TableForm[m, TableHeadings -> {rows, Rest@cols}, TableAlignments -> "."]
which produces:

However, I would like to center the column headings and remove all the trailing decimal points. I have not found any way to center just the column headings while keeping the values decimal/right aligned. I have seen some complicated methods of removing the decimal point by converting the values to a string and then doing string manipulations to remove the decimal point, which seems like a hack to me, so I am hoping there is a straightforward way.
Answer
Is this what you had in mind?
cosine[r_, theta_] := Sqrt[2 r^2 (1 - Cos[theta/360*2*Pi])];
m = Table[IntegerPart[cosine[r, t]], {r, 1000, 10000, 1000}, {t, 0.5, 2., .5}];
rows = Range[1000, 10000, 1000];
TableForm[m, TableHeadings -> {rows, {"0.5", "1.0", "1.5", "2.0"}}, TableAlignments -> Right]

Note that m is undefined in your question, but I surmise that my definition is close to what you intended.
Comments
Post a Comment