对于以下内容(省略了一些与包相关的语句):
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.
答案 0 :(得分:2)
应使用SetDelayed(:=
)定义函数,即
CartesianMap[func_, {x0_, x1_, dx_}, {y0_, y1_, dy_}] :=
Module[{x, y, tx, ty, llpx, llpy},
tx = ...