Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Extracting just the value of the variable from the result of Solve/NDSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62827] Re: Extracting just the value of the variable from the result of Solve/NDSolve
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at Gmail.com>
  • Date: Tue, 6 Dec 2005 00:04:06 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <dmpa43$hl7$1@smc.vnet.net> <200512032352.SAA15963@smc.vnet.net> <dn22gp$kvb$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Pradeep Suresh wrote:
> Hi all,
> i am facing a peculiar problem with the curly brackets of the output of 
> Solve and NDsolve commands....the result of Solve/NSolve/DSolve/NDSolve 
> all are in the form of {{y->a}} format and at best by doing a y/.soln, i 
> can get it to {a}, but for my purposes of passing this result to 
> JAVA(using J/Link), i need the value of the variable as just 'a' and not 
> '{a}'(i hope i am making myself clear).
> E.g.
> eqn={F==2*T};
> T = 300;
> sol = Solve[eqn, F]
> F /. sol
> 
> gives me {600}, as i said earlier i need the answer 600(which is 
> different in datatype compared to {600} even though for all practical 
> purposes {600} is the same as 600). When i use J/link to extract value, 
> the {600} is not considered an integer/string/double/function,...so i 
> cannnot use getInteger,getString etc.
> Can someone plz suggest a solution this problem, however triveal as it 
> may sound, it is an important problem in using J/Link to talk with 
> Mathematica.
> 
> Thank you very much in advance!!
> Regards,
> Pradeep
> 
Hi Pradeep,

Add a part specification to the the list of solutions {sol[[1]] in this 
case):

In[1]:=
eqn = F == 2*T;
sol = Solve[eqn /. T -> 300, F];
F /. sol[[1]]

Out[3]=
600


  • Prev by Date: Re: Re: A question about algebraic numbers using Mathematica
  • Next by Date: Re: Re: Re: Types in Mathematica thread
  • Previous by thread: Re: Extracting just the value of the variable from the result of Solve/NDSolve
  • Next by thread: Re: FixedPoint stops "when elements no longer change"?