[Date Index]
[Thread Index]
[Author Index]
Re: Text and multiple calculations in an IF condition
*To*: mathgroup at smc.vnet.net
*Subject*: [mg100996] Re: Text and multiple calculations in an IF condition
*From*: Bill Rowe <readnews at sbcglobal.net>
*Date*: Fri, 19 Jun 2009 20:48:19 -0400 (EDT)
On 6/18/09 at 8:47 PM, mail at pascal-schulthess.de (Pascal Schulthess)
wrote:
>I have a small problem, and haven't found any solution yet. So I
>hope you can help me.
>I'd like to have describing text, comments and multiple calculations
>when one condition is true, and others when it's false.
>For example:
>If[a>b,
>do something here;
>and something else here;
>insert a text here;
>else
>do something;
>and more;
>]
>As far as I tried this is not possible with the if condition
>provided?! But I also think this quite easy to do, if you know how
>to.
You really should post the Mathematica code you actually tried
to use. Then it would be possible to see what is wrong.
It is certainly possible to have code do as you've described.
In correct Mathematica syntax what you described would be done
as follows
If[a>b, expr1;expr2;expr3, expr4;expr5]
For this to work as intended a and b must have values that make
sense to compare. If no values are assigned, then Mathematica
will not be able to determine whether a is less than b or not.
Note, there is no semicolon after expr3 or expr5. If you want
text returned, it is essential not to terminate the expression
that returns the text with a semicolon. And finally, if you want
the If statement to evaluate to something even when a and b have
not been assigned values, the syntax is
If[a>b, expr1;expr2;expr3, expr4;expr5, expr6]
The last item, expr6 will evaluate when Mathematica is unable to
determine whether a<b is true or not.
Prev by Date:
**TeX output via TeXForm: variable name translation**
Next by Date:
**Re: Text and multiple calculations in an IF condition**
Previous by thread:
**Re: Text and multiple calculations in an IF condition**
Next by thread:
**Re: Text and multiple calculations in an IF condition**
| |