MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

How to use Needs inside While?

  • To: mathgroup at
  • Subject: [mg6302] How to use Needs inside While?
  • From: sergio at (Sergio Rojas)
  • Date: Sat, 8 Mar 1997 00:26:25 -0500 (EST)
  • Organization: City College Of New York - Science
  • Sender: owner-wri-mathgroup at

Hello fellows,

   If I put the expression Needs["Statistics`NonlinearFit`"] inside
a While loop, the function NonlinearFit does not work and Mathematica
output the error:

   Warning: Symbol NonlinearFit appears in multiple contexts 
    {Statistics`NonlinearFit`, Global`}; definitions in context 
    Statistics`NonlinearFit` may shadow or be shadowed by other definitions.

   If the statement is outside the loop,  no error is displayed and
NonlinearFit works fine. 

   How to use Needs["..."] inside any loop ?


 Needs["Statistics`NonlinearFit`"];(* here it works *) 

answer = 0;
While[ answer == 0,
(* Needs["Statistics`NonlinearFit`"]; (* here it does not work *)
    xmin = Input[" Enter xmin (try -4.)"];
    xmax = Input[" Enter xmax (try  0.)"];
    incr = Input[" Enter the increment (try 0.1)"];
    data = Table[{x, 1.5*Exp[1.5*x] + 1.5*Sin[1.5*x]}, {x, xmin, xmax, incr}];
    abcd = NonlinearFit[data, a*Exp[b*x] + c*Sin[d*x], x, {a,b,c,d}];
              a = a /. abcd ;
              b = b /. abcd ;
              c = c /. abcd ;
              d = d /. abcd ;
         Print[" a= ", a," ; b= ",b," ; c= ",c," ; d= ",d];
  answer = Input[" To try other interval, enter 0 and hit RETURN "]]


E-mail: sergio at

  • Prev by Date: Re: laplace transforms
  • Next by Date: Re: Creating an Attribute AntiSymmetric ?!?!?!
  • Previous by thread: Re: laplace transforms
  • Next by thread: Re: How to use Needs inside While?