help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: use solution of solve (symbolic)


From: Colin Macdonald
Subject: Re: use solution of solve (symbolic)
Date: Wed, 27 Mar 2019 15:52:09 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.3

On 2019-03-27 6:21 p.m., Doug Stewart wrote:
here is one way

solution=solve([eq1 eq2],[a b])
a1=solution.a
b1=solution.b
double(subs(dbl_a,a,a1))
double(subs(dbl_b,b,b1))

I agree with Doug.

In the *next* version of Symbolic (2.8.0, not out yet) you will also be able to use subs and/or eval to shortcut this a little bit:

syms a b
dbl_a=2*a
dbl_b=2*b
eq1=dbl_a==9
eq2=dbl_b==10
solution=solve([eq1 eq2],[a b])
a = solution.a
b = solution.b
eval(dbl_a)
eval(dbl_b)

The eval command will search your workspace for variables whose names match the symbols a and b.

Note: IMHO, this sort of thing might be nice for interactive command-line usage, but Doug's approach is better for code.

Colin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]