【问题标题】:Mathematica table error messagesMathematica 表错误消息
【发布时间】:2016-11-30 17:17:45
【问题描述】:

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

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. 消息是否有干净的解决方案?

【问题讨论】:

    标签: wolfram-mathematica message


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-04
      • 2017-04-26
      • 2015-09-18
      • 1970-01-01
      相关资源
      最近更新 更多