mathematica-8

How can I programmatically access information about a 'Graph` object in Mathematica 8?

半腔热情 提交于 2019-12-23 08:58:02
问题 I'm trying to access information within a Graph object in Mathematica 8. For some reason, the Part command does not seem to work. myGraph is the object I want to gain access to. The first line below displays myGraph. The others serve to inspect it. myGraph myGraph // FullForm myGraph // InputForm myGraph // OutputForm myGraph[[1]] myGraph[[2]] Why doesn't myGraph[[1]] return List[1,3,4,2,5] ? [I checked to level 2 just in case Graph were wrapped by some invisible wrapper. Level[myGraph,1] ,

Photo Mosaic in Mathematica: an example from 2008 doesn't work in Mathematica 8

两盒软妹~` 提交于 2019-12-21 16:18:53
问题 I'm trying to get a Mathematica example working. It's the one on Theo Gray's blog. I think that Mathematica must have changed since he wrote that code (May 2008), since I'm unable to get anything reasonable out of it, despite changing nearly everything. Do I use ImageData instead of Import? Can anyone suggest a version of this code that works for Mathematica 8? imagePool = Map[With[{i = Import[#]}, {i, Mean[Flatten[N[i[[1, 1]]], 1]]}] &, FileNames["Pool/*.jpg"]]; closeMatch[c_] :=

Photo Mosaic in Mathematica: an example from 2008 doesn't work in Mathematica 8

主宰稳场 提交于 2019-12-21 16:18:08
问题 I'm trying to get a Mathematica example working. It's the one on Theo Gray's blog. I think that Mathematica must have changed since he wrote that code (May 2008), since I'm unable to get anything reasonable out of it, despite changing nearly everything. Do I use ImageData instead of Import? Can anyone suggest a version of this code that works for Mathematica 8? imagePool = Map[With[{i = Import[#]}, {i, Mean[Flatten[N[i[[1, 1]]], 1]]}] &, FileNames["Pool/*.jpg"]]; closeMatch[c_] :=

A problem in Mathematica 8 with function declaration

删除回忆录丶 提交于 2019-12-21 12:31:46
问题 This is a strange result with a function defined as "functionB" in this example. Can someone explain this? I want to plot functionB[x] and functionB[Sqrt[x]] , they must be different, but this code shows that functionB[x] = functionB[Sqrt[x]] , which is impossible. model = 4/Sqrt[3] - a1/(x + b1) - a2/(x + b2)^2 - a3/(x + b3)^4; fit = {a1 -> 0.27, a2 -> 0.335, a3 -> -0.347, b1 -> 4.29, b2 -> 0.435, b3 -> 0.712}; functionB[x_] := model /. fit Show[ ParametricPlot[{x, functionB[x]}, {x, 0, 1}],

Mathematica: 3D wire frames

淺唱寂寞╮ 提交于 2019-12-17 19:43:08
问题 Does Mathematica support hidden line removal for wire frame images? If this isn't the case, has anybody here ever come across a way to do it? Lets start with this: Plot3D[Sin[x+y^2], {x, -3, 3}, {y, -2, 2}, Boxed -> False] To create a wire frame we can do: Plot3D[Sin[x+y^2], {x, -3, 3}, {y, -2, 2}, Boxed -> False, PlotStyle -> None] One thing we can do to achieve the effect is to color the all the surfaces white. This however, is undesirable. The reason is because if we export this hidden

How can I show % values on the y axis of a plot?

拟墨画扇 提交于 2019-12-13 12:06:16
问题 In any Mathematica chart or plot how can I show % values on the y axis? I may have data like this: data = {{{2010, 8, 3}, 0.}, {{2010, 8, 31}, -0.052208}, {{2010, 9, 30}, 0.008221}, {{2010, 10, 29}, 0.133203}, {{2010, 11, 30}, 0.044557}, {{2010, 12, 31}, 0.164891}, {{2011, 1, 31}, 0.055141}, {{2011, 2, 28}, 0.114801}, {{2011, 3, 31}, 0.170501}, {{2011, 4, 29}, 0.347566}, {{2011, 5, 31}, 0.461358}, {{2011, 6, 30}, 0.244649}, {{2011, 7, 29}, 0.41939}, {{2011, 8, 31}, 0.589874}, {{2011, 9, 30},

How to use InterpolatingFunction generated by Mathematica 5.2 in version 8.0.1?

别等时光非礼了梦想. 提交于 2019-12-13 02:30:20
问题 Let us interpolate the same data using Mathematica 5.2, 7.0.1 and 8.0.1: Interpolation[{{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}}] // InputForm The outputs are: Mathematica 5.2: InterpolatingFunction[{{0, 5}}, {2, 0, True, False, {3}, {0}}, {{0, 1, 2, 3, 4, 5}}, {{0}, {1}, {3}, {4}, {3}, {0}}, {Automatic}] Mathematica 7.0.1: InterpolatingFunction[{{0, 5}}, {3, 1, 0, {6}, {4}, 0, 0, 0, 0}, {{0, 1, 2, 3, 4, 5}}, {{0}, {1}, {3}, {4}, {3}, {0}}, {Automatic}] Mathematica 8.0.1:

Any efficient easy way to find the maximum list among N lists with the same length using Mathematica?

北城以北 提交于 2019-12-11 02:25:00
问题 This question is a continuation of a previous thread to compare two lists with the same length: Is there any efficient easy way to compare two lists with the same length with Mathematica? Given two lists A={a1,a2,a3,...an} and B={b1,b2,b3,...bn} , I would say A>=B if and only if all ai>=bi . Now we have k lists H={{a11,a12,a13,...a1n}, {a21,a22,a23,...a2n},...,{ak1,ak2,ak3,...akn}} , and want to find the maximum one if exist. Here's my code: Do[If[NonNegative[Min[H[[i]] - h]], h = H[[i]], ##

Avoid repeated calls to Interpolation

穿精又带淫゛_ 提交于 2019-12-09 16:50:20
问题 I want to interpolate a function in mathematica. The function depends on a parameter a , in fact it is the inverse of a function F which also depends on a , so I build my approximation as follows, approx = Interpolation[Table[{F[0.1 n, a], 0.1 n}, {n, -100, 100}]] now I can simply call approx[x] to evaluate the inverse function at a point. Instead I would like to do something like this: Define a function which takes a parameter, G[x_,a_] = "construct the interpolating function, and return the

Line Style using Graphics3D in Mathematica

冷暖自知 提交于 2019-12-07 18:01:57
问题 Consider the following : cAxes = {{{0, 0, 0}, {0, 0, 1}}, {{0, 0, 0}, {0, 1, 0}}, {{0, 0,0}, {1, 0, 0}}}; Graphics3D[{Line /@ cAxes}, Boxed -> False] How can Style differently the 3 lines ? 回答1: The answer above are good, but I want to show some alternatives. I show that it is possible to use Style for this, and that Tube is an interesting alternative to Line . cAxes = {{{0, 0, 0}, {0, 0, 1}}, {{0, 0, 0}, {0, 1, 0}}, {{0, 0, 0}, {1, 0, 0}}}; tubes = Tube@# ~Style~ #2 & ~MapThread~ {cAxes,