Hot answers tagged

8

Since you want to test the last element of each {x, y, z, a1[x]}, I'd modify C.E.'s suggestion in the comments to make sure that cases where Pi/2 appears at any other locations don't get thrown away: DeleteCases[t, {_, _, _, Pi/2}, {3}] /. {} -> Nothing This pattern first throws away the structure you don't want, and then the replacement drops the ...


4

I would suggest not to flatten the table, since the relevant information is contained in its formatting and can be extracted by Part and Total. T = ParallelTable[{x, y, z, k, fff[x, y, z, k]}, {x, 0, 1, 0.1}, {y, 0.5, 5.5, 1}, {z, 0.2, 2, 0.2}, {k, 0.2, 1, 0.2}]; fvalues = T[[All, All, All, All, 5]]; xy = T[[All, All, 1, 1, 1 ;; 2]]; averages = Total[fvalues,...


3

You may use Query with GroupBy. assoc = Query[ GroupBy[#[[;; 2]] &] , Mean@#[[All, -1]] & ]@tabb; Short@assoc <|{0., 0.5} -> 2.074*10^12, <<64>> , {1., 5.5} -> 0.00023595|> This gives the result as an Association with the keys the x-y pairs. assoc[{0., 0.5}] 2.074*10^12 However, this can be easily converted ...


3

Lot's of ways to achieve this. A few follow: list1 = {"list1", 1/x, -1 + x, -(x/(-2 + x)), -1 + 1/x, -1 + 2 x}; list2 = {"list2", {{a, b}}, {{c, d}}, {{a, c}, {b, d}}, {{e, f}, {g, h}}, {{k, t}}}; list3 = {"No.", 1, 2, 3, 4, 5}; Grid[Transpose[{list3, list2, list1}], Frame -> All] This gets a bit closer: list1 = {"...


2

As mentioned by @BobHanlon in the comments, the solution is to use RuleDelayed in the following way: tr[a^2]^5 /. tr[a^k_]^l_ :> t[Sequence @@ Table[k, {i, 1, l}]] (* t[2,2,2,2,2] *) This produces the desired output.


2

Table already puts it's element in a row. To build your Listplot, it looks lie you just need to Flatten. tst1 = {0, 0, 0, 8, 15, 18, 19, 20, 25, 30, 28, 20, 18, 16, 14, 12, 11, 10, 8, 6, 4, 3, 2, 1, 0.5}; tst2 = {0, 0, 0, Table[tst1[[i]], {i, 4, 25}]} // Flatten ListPlot[Table[{tst1[[i]], tst2[[i]]}, {i, 25}]]


1

Try inspecting the plots of {s1,s2,f1[...]-1} and {s1,s2,f2[...]-1} where ... is your parameter set. (I've replaced your functions with f1 and f2 using NIntegrate to speed things up): f1[S1_, S2_, γ_, β1_, β2_, δ1_, δ2_,α11_, α12_] := (γ*β1)/δ1*NIntegrate[Exp[-γ*a]*(1 - Exp[-δ1*a])*Exp[-S1*(α11*β1)/δ1 (1 - Exp[-δ1*a]) - S2*(α12*β2)/δ2 (1 - Exp[-δ2*a])], {a,0,...


1

Since both of them are an arithmetic sequence (a sequence with equal step size) you can use Differences: h = Table[i, {i, 0, 5, 1}]; p = Table[j, {j, 0, 255, 51}]; If you apply once, you'll get step size: Differences[h] (* Out: {1,1,1,1,1} *) Differences[p] (* Out: {51,51,51,51,51} *) Now you can use various ways to equate them, here we'll use another ...


1

Thanks to the @cvgmt's feedback, alternatives to Transpose: Code 1 Thread[{list1, list2}] % == Transpose[{list1, list2}] (* Out: True *) Code 2 Can only be used on two lists, each of them should be 1-dimensional: Inner[List, list1, list2, List] % == Transpose[{list1, list2}] (* Out: True *) Speed Comparison lg[n_] := ConstantArray[RandomReal[{-1, 1}, 10^...


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