From: Crystal Nassouri on 30 Mar 2010 18:28 Hi Walter, Thanks for your reply. I updated my while loop: while Lnext > -2 c = 10^(n+1) H = vpa(x2k) Lnext = Lk + c*H %ARRRG WHY ISNT IT SUBSTITUTING? Lk = Lnext n = n+1; end I moved my H inside the loop since it is dependent on c. "double" doesnt seem to work for symbolics so I used vpa, but I am still getting a symbolic result out of Lnext and Lk: (spacing removed) Lk =0 c =10 H = -(1.0*(Lk - 3.0))/(c - 1.0) Lnext = -(10.0*(Lk - 3.0))/(c - 1.0) Lk =-(10.0*(Lk - 3.0))/(c - 1.0) Any other suggestions? Walter Roberson <roberson(a)hushmail.com> wrote in message <hotmeu$kji$2(a)canopus.cc.umanitoba.ca>... > Crystal Nassouri wrote: > > > The problem is in: > >> while Lnext > -2 > >> c = 10^(n+1) > >> Lnext = Lk + c*H %ARRRG WHY ISNT IT SUBSTITUTING? > >> Lk = Lnext > >> n = n+1; > >> end > > > > Where Lnext does take in the val for Lk and c, but does not take H > > numerically. When I run the program, I can see that Lnext is still > > symbolic because for some reason H is symbolic even though I have given > > it all required values. > > If you have a numeric symbolic expression that you want to evaluate to a > hardware floating point number, call double() on the expression and save the > result. In your case you could do that outside the loop (because H does not > change within the loop.) |