Equation solving to get a function
1 view (last 30 days)
Show older comments
Ayca Altay
on 24 Jan 2018
Answered: Walter Roberson
on 24 Jan 2018
I am trying to solve a set of Laplace equations and get three functions. My code is as
syms l lr lc mu s
syms p2(s,l,lr,lc,mu) p1(s,l,lr,lc,mu) p0(s,l,lr,lc,mu)
eqn0=s*p0==lr*p1+lc*p2;
eqn1=s*p1==2*l*p2-lr*p1-mu*p1;
eqn2=s*p2-1==mu*p1-2*l*p2-lc*p2;
eqn=[eqn0,eqn1,eqn2];
[p0sol, p1sol, p2sol]=solve(eqn, [p0, p1, p2])
I am trying to find the functions p0, p1 and p2.
This produces and error saying "The second argument must be a vector of symbolic variables". I found a bunch of threads about this error but could not relate to this formulation.
How do I get what these functions are?
0 Comments
Accepted Answer
Walter Roberson
on 24 Jan 2018
It is not possible to solve with respect to a function; you can only solve with respect to a variable.
syms l lr lc mu s
syms p0 p1 p2
eqn0 = s*p0 == lr*p1+lc*p2;
eqn1 = s*p1 == 2*l*p2-lr*p1-mu*p1;
eqn2 = s*p2-1 == mu*p1-2*l*p2-lc*p2;
eqn = [eqn0,eqn1,eqn2];
[p0sym, p1sym, p2sym] = solve(eqn, [p0, p1, p2])
p0sol = symfun(p0sym, [s,l,lr,lc,mu]);
p1sol = symfun(p1sym, [s,l,lr,lc,mu]);
p2sol = symfun(p2sym, [s,l,lr,lc,mu]);
0 Comments
More Answers (0)
See Also
Categories
Find more on Number Theory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!