| Author |
Comment/Response |
Abed Alnaif
|
02/18/13 8:31pm
Hello,
I am trying to make a package which plots some equation, but I am having trouble doing this. My issue is best illustrated with an example:
First, make a package, which has a module 'testPlot' which plots a given equation 'eqn':
BeginPackage["testPlotPckg`"]
testPlot::usage = "None until I get it to work.";
Begin["`Private`"];
testPlot[eqn_]:=Module[{},Plot[y[x]/.eqn,{x,0,2}]]
End[ ];
EndPackage[ ];
Now, the main program:
ClearAll["Global`*"]
<< "testPlotPckg.m" (*You may have to change this line so that it points to the right directory.*)
eqn = y[x] -> x;
Plot[y[x] /. eqn, {x, 0, 2}] (*This works, producing the expected plot.*)
testPlot[eqn] (*This does not work.*)
I think the issue has to do with variable contexts in the package, relating to the variable 'x'. But I'm not sure how to fix this (or if this is really the issue). I also tried the following, but this also didn't work:
BeginPackage["testPlotPckg`"]
testPlot::usage = "None until I get it to work.";
Begin["`Private`"];
testPlot[eqn_]:=Module[{},Plot[y[x]/.eqn,{Global`x,0,2}]]
End[ ];
EndPackage[ ];
I am using Wolfram Mathematica 7 for Students.
URL: , |
|