wolfram-mathematica

List Manipulation in Mathematica pertaining to Lagrange Interpolation Polynomials in Mathematica

依然范特西╮ 提交于 2019-12-11 06:54:19
问题 I am trying to use a list which is passed to a function in such a way that I can get the length of that list get the individual x and y values to manipulate The list I am trying to manipulate can be seen below: dataTan = Table[{x, Tan[x]}, {x, -1.5, 1.5, .75}]; this question is a sort of a follow-up to the question seen here. I eventually want to write my own function in mathematica that generates the Lagrange Interpolation polynomial for a given set of points {{x0, y0}, ... , {xn, yn}} I

Plot DelaunayTriangulation in Mathematica

女生的网名这么多〃 提交于 2019-12-11 06:52:03
问题 Considering the following example (from Sjoerd Solution on plotting a ConvexHull) Needs["ComputationalGeometry`"] pts = RandomReal[{0, 10}, {60, 2}]; dtpts=DelaunayTriangulation[pts] I would now like to plot the DelaunayTriangulation for a set of point but can`t figure out the Plot syntax using Graphics. Thoughts ? 回答1: Graphics[ GraphicsComplex[ pts, { Function[{startPt, finishPts},Line[{startPt, #}] & /@ finishPts] @@@ dtpts, Red, Point@Range[Length@pts] } ] ] And if you need real polygons:

Clearing numerical values in Mathematica

让人想犯罪 __ 提交于 2019-12-11 06:49:47
问题 I am working on fairly large Mathematica projects and the problem arises that I have to intermittently check numerical results but want to easily revert to having all my constructs in analytical form. The code is fairly fluid I don't want to use scoping constructs everywhere as they add work overhead. Is there an easy way for identifying and clearing all assignments that are numerical? EDIT: I really do know that scoping is the way to do this correctly ;-). However, for my workflow I am

Image of wire frame from 3Dgraph-can it be exported

青春壹個敷衍的年華 提交于 2019-12-11 06:24:39
问题 Can a wireframe plot made with mathematica be turned into a transparent image and then exported to another site? The reason for this question is that I am trying to fit the wireframe to a structure. 回答1: The following code allows to export to GIF with transparent background (based on Mr.Wizard's code): g = Plot3D[{x^2 + y^2, -x^2 - y^2}, {x, -2, 2}, {y, -2, 2}, RegionFunction -> Function[{x, y, z}, x^2 + y^2 <= 4], BoxRatios -> Automatic, PlotStyle -> None, Axes -> None, Boxed -> False]

how to store the data from each loop into an array or table form?

妖精的绣舞 提交于 2019-12-11 06:09:23
问题 For[n = 1, n < 6, n = n + 1, For[m = 1, m < 6, m = m + 1, abc = doc[[n]]; kk = doc[[m]]; v =vector[abc, kk]; vl = VectorLength[v]]] I want to store the data from each loop into an array or table form. How can I do that? 回答1: Try using a Table instead of two For loops. It returns a list of lists of the results (a matrix basically) Table[ abc = doc[[n]]; kk = doc[[m]]; v = vector[abc, kk]; vl = VectorLength[v], {n, 1, 5}, {m, 1, 5}] 回答2: It's not clear to me what data you want to save, but the

Plot VoronoiDiagram using Graphics in Mathematica

◇◆丶佛笑我妖孽 提交于 2019-12-11 05:29:23
问题 Completing questions on how to plot a ConvexHull or a DelaunayTriangulation using Graphics in Mathematica, I would now like to plot the VoronoiDiagram within Graphics. Considering : Needs["ComputationalGeometry`"] pts = RandomReal[{0, 10}, {60, 2}]; vdpts=VoronoiDiagram[pts] 回答1: How about Needs["ComputationalGeometry`"] pts = RandomReal[{0, 10}, {10, 2}] DiagramPlot[pts] or am I missing your point? 来源: https://stackoverflow.com/questions/6477753/plot-voronoidiagram-using-graphics-in

Adding a Third column of data in Mathematica

匆匆过客 提交于 2019-12-11 04:56:41
问题 I have a very large table of data something like: lista = {{2,8},{3,4},{5,2}..} I would like to add x to every element so it would be lista ={{x,2,8},{x,3,4},{x,5,2}.....} This seems to me like it should be rather trivial but I have not been able to find a solution. I would appreciate any help. 回答1: This is very nearly a duplicate of Appending to the rows of a table and an exact duplicate of Prepend 0 to sublists on the dedicated site where your question should have been asked. Many more

How to intercept assigning new value for the In variable?

六月ゝ 毕业季﹏ 提交于 2019-12-11 04:46:51
问题 I wish to intercept assigning new values for the In variable. I have tried to do this by defining UpValues for In but it does not help in this case: Unprotect[In]; In /: Set[In[line_], expr_] /; ! TrueQ[$InsideSet] := Block[{$InsideSet = True}, Print[HoldForm@HoldForm[expr]; Set[In[line], expr]]] In /: SetDelayed[In[line_], expr_] /; ! TrueQ[$InsideSet] := Block[{$InsideSet = True}, Print[HoldForm@HoldForm[expr]; SetDelayed[In[line], expr]]] Is it possible to intercept it? P.S. This question

Getting VertexRenderingFunction to (not) scale

天涯浪子 提交于 2019-12-11 02:56:11
问题 I'm having problem with custom VertexRenderingFunction showing at different sizes for different graphs. An example is below, the default vertex rendering function has the desired behavior since vertices look the same in all graphs, any suggestion how to achieve that with custom vertices? (source: yaroslavvb.com) edges = Most[ ArrayRules[GraphData[{"Path", 5}, "AdjacencyMatrix"]]][[All, 1]]; doit[vrf_] := Print /@ Table[ GraphPlot[Rule @@@ edges[[k ;;]], VertexRenderingFunction -> vrf,

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]], ##