Equation solving to get a function
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ayca Altay
am 24 Jan. 2018
Beantwortet: Walter Roberson
am 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Number Theory finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!