Equation solving to get a function
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Walter Roberson
2018년 1월 24일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Number Theory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!