Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: cannot work a "conditional If"
Replies: 1   Last Post: Apr 24, 2013 6:16 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Bob Hanlon

Posts: 892
Registered: 10/29/11
Re: cannot work a "conditional If"
Posted: Apr 24, 2013 6:16 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


Your output of signy is a list of length 1 rather than a number.
Consequently, the test in the If does not evaluate as either True or False
and the If statement returns unevaluated. Change the definition of signy to
produce a number, i.e.,


signy[t_] := y[t] /. orbit[[1]]


However, rather than use an If statement, I recommend that you use
Piecewise.



Bob Hanlon




On Mon, Apr 22, 2013 at 3:11 AM, <patrice.haldemann@gmail.com> wrote:

> Hi everybody
>
> I am a newcomer in the mathematica world and I have been facing an issue
> for some days.
>
> I have used mathematica to solve an NDSolve and it has worked well
>
> I have tested expressions with the solution of NDSolve and its has worked
> well.
>
> Now if I use an expression in an "Conditional If", it does not work.
>
> Thank you for your help
>
>
> See below
>
> signy[t_] := y[t] /. orbit where y[t] is the solution of the NDSolve
>
> signy[1]
>
> {-1.96861}
>
> ang12[t_] := If[signy[t] > 3, 10, 6]
>
> ang12[1]
>
> If[{-1.96861} > 3, 10, 6]
>
>




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.