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: Doug Stewart
Subject: Re: use solution of solve (symbolic)
Date: Wed, 27 Mar 2019 17:21:28 -0400



On Wed, Mar 27, 2019 at 4:58 PM Stef Pillaert <address@hidden> wrote:
Hello,
I must me missing something obvious, but can't find a simple solution:
I have two symbolic variables (a,b) and two other variables depending on
them (dbl_a, dbl_b).
I solve two equations, which I can solve for a and b.
How do I "substitute" those solutions into the depending variables, so I can
see what their values are?

pkg load symbolic
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
vpa(dbl_a)
vpa(dbl_b)

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))



 
When I run this, I get:

a = (sym) 9/2
b = (sym) 5
ans = (sym) 2.0*a
ans = (sym) 2.0*b

But I need the last two lines to return "9" and "10", to inspect the values.
I allready tried to use "subs", without succes....
Of course, I can change the last two lines to "vpa(dbl_a=2*a)" and
"vpa(dbl_b=2*b)", but actually my calculations and equations are a lot more
complex, this is a MWE
Many thanks for any help,
Stef



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html




--
DASCertificate for 206392


reply via email to

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