Tag Info

Hot answers tagged

2

This is a canonical way of getting what you want: data = Table[i[j], {i, {f, g}}, {j, 1, 5}]; TraditionalForm@TableForm[ data, TableHeadings -> {{f, g}, Range[5]}] \begin{array}{c|ccccc} \text{} & 1 & 2 & 3 & 4 & 5 \\ \hline f & f(1) & f(2) & f(3) & f(4) & f(5) \\ g & g(1) & g(2) & g(3) & ...


2

ListPlot requires lists of point coordinates, but the code was providing it with lists of lists. This can be fixed by replacing the last two lines by yvar = Transpose[Table[MF[[1, ii]][[2]], {ii, 1, 5}]]; ListPlot[Table[{xvar[[i]], yvar[[j, i]]}, {i, 5}, {j, 8}], PlotStyle -> Black] Is this what you had in mind?


2

I figured it out. Export["~/Desktop/test.txt", {{2334252, 1}, {2, 235211234}}, "Table", "FieldSeparators"->" ", Alignment->Left] Instead of Left you can also use Center/Right. The options for Export with different formats aren't very easy to find in the documentation!


2

Of OP's two requirements center the column headings and remove all the trailing decimal points. @bbgodfrey's answer addresses the second. Unfortunately, getting both requirements, i.e., to center just the column headings while keeping the values decimal/right aligned. using TableForm is impossible since TableAlignments is not flexible enough to ...


2

What you have laid out is inefficient in a number of ways. But, I will tackle your question, as is, first, then I will lay out how I would approach it. Since your bottleneck is Table[{j dx, k dy, p[j, k] /. sol}, {j, 1, m}, {k, 1, m}] you need to use a more efficient layout for your replacement rules: Dispatch. Replace sol = Solve[eqns, vars][[1]]; ...


2

list1 = {{0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 1, 0}, {1, 1, 1, 1}}; list2 = {1, 5, 5, 5}; Grid[Prepend[Transpose[{Row[{"(", Row[#, ","], ")"}] & /@ list1, list2}], {"Initial Vector", "Period"}], Dividers -> {2 -> True, 2 -> True}] or Grid[Join[{{"Initial Vector", "Period"}}, Transpose[{Row[{"(", Row[#, ","], ")"}] & /@ ...


2

Based on your self-answer I think you want this: SeedRandom[0] FullTab1 = RandomComplex[{0 I + 0, 2 I + 2}, {20, 3}]; (* example data *) sel = Select[FullTab1, Im[First[#]] > 0.9 &]; lgt = Length @ sel; {ext, mx1, mx2} = Transpose[{Re@sel, Im@sel}, {3, 2, 1}]; ListPlot[ext] ListPlot[mx1] ListPlot[mx2]


1

Without comment on whether this is the best solution for your paticular problem, this can be achieved by the following pattern: Table[ If[condition, value, Unevaluated@Sequence[]], ... ] Nulls will stay, Sequence[]s will disappear. For large problems this may be better: Reap@Do[ If[condition, Sow[value]], ... ] Check Sow/Reap in the ...


1

Table[If[Mod[n!, n^(2 n)] == 0, n], {n, 1, 1000}] /. Null -> Sequence[] {1} Cases[Table[If[Mod[n!, n^(2 n)] == 0, n], {n, 1, 1000}], _?NumericQ] {1} Select[Table[If[Mod[n!, n^(2 n)] == 0, n], {n, 1, 1000}], NumericQ[#] &] {1} DeleteCases[Table[If[Mod[n!, n^(2 n)] == 0, n], {n, 1, 1000}], Null] {1}


1

You might want to try the following construct, which replaces the iterative code with Mathematica constructs and reduces the need for many of the variables: Table[Sum[func[iii*h-L,h*n-L],{n,0,Nn-1}],{iii,0,Nn-1}]


1

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 ...


1

The code below can reproduce the Log Table shown here. logTable[upto_] := Module[{}, mantissa[num_] := Flatten[{num, Table[Rationalize[FractionalPart[N[Log10[num*10 + j], 5]]], {j, 0, 9}]}]; meanDiff[num_] := Module[{}, Table[ Round[Total[ Table[N[Log10[num*100 + i*10 + j], 6] - N[Log10[num*100 + i*10], 6], {i, 0, 9}]]*10^3], {j, 1, ...


1

I´m not sure whether I understood you right, but a simple table can be created via, e.g. Table[{x, Log[x]}, {x, 1, 2, 0.05}] // TableForm with Grid you can produce this a bit more "stylish": out = Table[{x, Log[x]}, {x, 1, 2, 0.05}]; Grid[Prepend[out, {"x", "Log[x]}"}], Frame -> All] Furthermore you can use all the "Style" options to brush this up. ...



Only top voted, non community-wiki answers of a minimum length are eligible