How to solve equations

1 visualización (últimos 30 días)
Awais Saeed
Awais Saeed el 17 de Dic. de 2018
Comentada: Walter Roberson el 19 de Dic. de 2018
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 19 de Dic. de 2018
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 comentarios
Awais Saeed
Awais Saeed el 19 de Dic. de 2018
Why 'Pi' should be detected as transcendental?
Walter Roberson
Walter Roberson el 19 de Dic. de 2018
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.)

Iniciar sesión para comentar.

Más respuestas (1)

Elijah Smith
Elijah Smith el 18 de Dic. de 2018
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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by