Mathematica表错误消息

时间:2016-11-30 17:17:45

标签: wolfram-mathematica message

对于以下内容(省略了一些与包相关的语句):

CartesianMap[ func_, {x0_,x1_,dx_}, {y0_,y1_,dy_} ] = 
  Module[ { x, y, tx, ty, llpx, llpy},
    tx = Table[{Re[func[x + I y]], Im[func[x + I y]]}, 
                  {x, x0, x1, dx}, {y, y0, y1, dy}]; 
    ty = Table[{Re[func[x + I y]], Im[func[x + I y]]}, 
                  {y, y0, y1, dy}, {x, x0, x1, dx}];
    llpx = ListLinePlot[tx];
    llpy = ListLinePlot[ty];
    Show[ llpx, llpy, Axes -> True, AspectRatio -> Automatic, 
                 ImageSize -> Large]
  ]

CartesianMap[ Cos, { 0.2, Pi - 0.2, (Pi - 0.4)/19}, {-2, 2, 4/16}]

执行时:

In[99]:= << CartesianMap1.m

我收到以下错误:

During evaluation of In[99]:= Table::iterb: Iterator {x$31836,x0,x1,dx} does not have appropriate bounds. >>

During evaluation of In[99]:= Table::iterb: Iterator {y$31836,y0,y1,dy} does not have appropriate bounds. >>

During evaluation of In[99]:= ListLinePlot::lpn: Table[{Re[func[x$31836+I y$31836]],Im[func[x$31836+I y$31836]]},{x$31836,x0,x1,dx},{y$31836,y0,y1,dy}] is not a list of numbers or pairs of numbers. >>

During evaluation of In[99]:= ListLinePlot::lpn: Table[{Re[func[x$31836+I y$31836]],Im[func[x$31836+I y$31836]]},{y$31836,y0,y1,dy},{x$31836,x0,x1,dx}] is not a list of numbers or pairs of numbers. >>

During evaluation of In[99]:= Show::gcomb: Could not combine the graphics objects in Show[ListLinePlot[Table[{Re[func[x$31836+Times[<<2>>]]],Im[func[x$31836+Times[<<2>>]]]},{x$31836,x0,x1,dx},{y$31836,y0,y1,dy}]],ListLinePlot[Table[{Re[func[x$31836+Times[<<2>>]]],Im[func[x$31836+Times[<<2>>]]]},{y$31836,y0,y1,dy},{x$31836,x0,x1,dx}]],Axes->True,AspectRatio->Automatic,ImageSize->Large]. >>

**************************************************************
End error messages.
  1. 生成的图形很好。
  2. 问题是在编译时表的迭代器是参数,所以没有定义。检查应该在运行时,而不是编译时。 Wolfram的决定不好。
  3. 使用Quiet [...]前缀所有语句很难看。
  4. 这些消息是否有干净的解决方案?

1 个答案:

答案 0 :(得分:2)

应使用SetDelayed:=)定义函数,即

CartesianMap[func_, {x0_, x1_, dx_}, {y0_, y1_, dy_}] :=
  Module[{x, y, tx, ty, llpx, llpy},
  tx = ...