2016-11-30 8 views
1

Für folgende (einige Paket bezogenen Aussagen weggelassen):Mathematica Tabelle Fehlermeldungen

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}] 

Wenn ich ausführen:

In[99]:= << CartesianMap1.m 

ich die folgenden Fehler:

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. Die generierten Grafiken sind gut.
  2. Das Problem ist, dass zum Zeitpunkt der Kompilierung die Iteratoren für Tabelle Argumente sind, also nicht definiert. Die Überprüfung sollte zur Laufzeit erfolgen, nicht zur Kompilierzeit. Schlechte Entscheidung von Wolfram.
  3. Präfixing alle Aussagen mit Quiet [...] ist hässlich.
  4. Gibt es eine saubere Lösung für die Nachrichten?

Antwort

2

Funktionen sollten mit SetDelayed (:=), d.h.

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