MathGroup Archive 1996

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

Search the Archive

Re: If statement inside Do loop

  • To: mathgroup at
  • Subject: [mg4651] Re: If statement inside Do loop
  • From: wagner at (Dave Wagner)
  • Date: Thu, 22 Aug 1996 03:55:06 -0400
  • Organization: University of Colorado, Boulder
  • Sender: owner-wri-mathgroup at

In article <4v166s$f8k at>,
Heather Mary Hauser <gt1824a at> wrote:
>I apologize for the length of this post, but the problem is driving me crazy.
>Mathematica ignores the If statement inside this Do loop. The program runs
>fine, no error messages, but it doesn't do what I want it to. Any help on why
>this is would be greatly appreciated.
>relevant part of program follows:

Here's your problem:

>  lstrl = First[rlist]; lstim = Firts[imlist];

You've mispelled "First".  Now lstim and every value obtained from
it will contain the expression Firts[imlist], which doesn't evaluate.

>  comre = N[Evaluate[lstrl*recon]];
>  comim = N[Evaluate[lstim*imcon]];
> If[comre <= 0 && comim <= 0, Print["instability near", omi],
>     Print["no"]];

comim is not a numeric expression, hence the expression comim <= 0
does not evaluate.  Therefore the If does not evaluate to either
of the alternatives.

What you should do in the future to find problems like this is use
the four-parameter form of If:

	If[test, true clause, false clause, neither clause]

After noticing that test is neither true nor false, you can then insert
Print statements to narrow down the problem.  In this case, the problem
was easy to find by inspection.

By the way, I haven't run your code, so I don't know if this is the
only problem with it.

		Dave Wagner
		Principia Consulting
		(303) 786-8371
		dbwagner at


  • Prev by Date: new Package: Transform2DPlot.m
  • Next by Date: Re: --->What is the problem with 'ParametricPlot'?
  • Previous by thread: Re: If statement inside Do loop
  • Next by thread: Hermite Polynomials of fractional order