Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Why the loop gain no result?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126084] Re: Why the loop gain no result?
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sun, 15 Apr 2012 03:19:43 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

On 4/14/12 at 3:10 AM, geotom.cao at gmail.com (Huafeng Cao) wrote:

>I use the' For' loop to solving an equation, such as : For[i = 1, i
>< 5, i++, a = i; Solve[a*x^2 - 2 x + 1 == 0, x]].The
>'a' in the body must be updated in every loop with the 'i'. But i
>cann' t gain the result,Somewhere is disorder? I am confused.

 From the documentation for For

Unless an explicit Return is used, the value returned by For is Null

And that is why your code doesn't display any result. Instead of
using For, use Table, i.e.

Table[Solve[a*x^2 - 2 x + 1 == 0, x], {a, 5}]




  • Prev by Date: Re: Why the loop gain no result?
  • Next by Date: Re: maximal information coefficient in Mathematica
  • Previous by thread: Re: Why the loop gain no result?
  • Next by thread: Re: Why the loop gain no result?