How to solve equations

조회 수: 4 (최근 30일)
Awais Saeed
Awais Saeed 2018년 12월 17일
댓글: Walter Roberson 2018년 12월 19일
Eq1 : x = 2*pi + 1*pj + 3*pk
Eq2 : y = 5*pi + 9*pj + 2*pk
Eq3 : 1 = pi + pj + pk
Let's say i have calculated pi,pk,pj using solve() command with x,y given. How can i find x,y back with the pi,pj,pk that i found.

채택된 답변

Walter Roberson
Walter Roberson 2018년 12월 19일
syms x y pi_ pj pk %pi would be detected as the transcendental
Eq1 = x == 2*pi_ + 1*pj + 3*pk;
Eq2 = y == 5*pi_ + 9*pj + 2*pk;
Eq3 = 1 == pi_ + pj + pk;
sol = solve([Eq1, Eq2, Eq3], [pi_, pj, pk]);
subs([Eq1,Eq2,Eq3], sol)
I have sent a bug report to Mathworks about the undocumented treatment of sym pi as being the transcendental constant instead of just a variable name, but my expectation is that the bug report will lead to documentation of the special behavior rather than changing the behavior.
  댓글 수: 2
Awais Saeed
Awais Saeed 2018년 12월 19일
Why 'Pi' should be detected as transcendental?
Walter Roberson
Walter Roberson 2018년 12월 19일
sym('Pi') is not detected as the transcendental constant, but sym('pi') is. When working with the Symbolic toolbox, you want to be able to enter expressions such as sin(10*pi*x) and have the pi standard for the transcendental π rather than standing for 3.141592653589793115997963468544185161590576171875 as it does in numeric MATLAB.
The character π is not part of MATLAB's basic character set and requires UTF-8 to encode, with UTF-8 not being turned on for most MATLAB installations. The character π is also not recognized by the symbolic engine. So users need some expression in the basic character set to represent the transcendental π to the symbolic engine, and that has been done by sym('pi') since at least the time that Mathworks switched to MuPAD in R2007b. [I would need to double check history to see whether it was sym('Pi') in the Maple based symbolic toolbox before that time.)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Elijah Smith
Elijah Smith 2018년 12월 18일
I'm not sure if I understand what your asking. If you are saying that you have the values for pi, pj, and pk already then you can define those variables and just type each line into a script or the command window:
x = 2*pi + 1*pj + 3*pk;
y = 5*pi + 9*pj + 2*pk;
If this is not what you are looking for then please elaborate.

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by