How can i see the end of the equation. Text exceeds maximum line length of 25,000 characters for Command Window display.
7 views (last 30 days)
Show older comments
I would like to know how can I see the solution for the following system of equations:
a=(b-x)*(c-x)+(d-y)*(e-y)+(f-z)*(g-z)
j=(k-x)*(l-x)+(m-y)*(n-y)+(o-z)*(p-z)
h=(b-x)*(l-x)+(d-y)*(n-y)+(f-z)*(p-z)
When I try to find the solution for these 3 equations for X, Y and Z, I can't see the complete answer.
Best regards, Jose
2 Comments
Geoff Hayes
on 17 Jan 2016
Jose - how are you solving the above equations such that the solution produces a line length of more than 25000 characters? Please post your code.
Answers (2)
Walter Roberson
on 18 Jan 2016
Basically you tell the symbolic engine to write it to a file, and then you look at the file.
So,
feval(symengine, 'write', 'Text', 'YourFile.txt', S.x);
and now you can view YourFile.txt using your favorite method.
You might also wish to consider
matlabfunction(S.x, 'file', 'YourFile.txt', 'Optimize', false)
This is not exactly the same because it converts the expressions to MATLAB code (or tries to.) There are some aspects of symbolic expressions that use a slightly different notation than MATLAB Code (which is why you should never eval() a symbolic expression) and you can get confused moving back and forth between the notations.
Olatunji Omisore
on 7 Nov 2016
@Jose Lopes, Hi Did you eventually solve the problem above because I have similar challenge. Could you please guide me how to read through the text?
2 Comments
Walter Roberson
on 7 Nov 2016
syms a b c d e f g h j k l m n o p x y z
eqn = [a==(b-x)*(c-x)+(d-y)*(e-y)+(f-z)*(g-z)
j==(k-x)*(l-x)+(m-y)*(n-y)+(o-z)*(p-z)
h==(b-x)*(l-x)+(d-y)*(n-y)+(f-z)*(p-z)]
S = solve(eqn, [x, y, z])
matlabFunction([S.x, S.y, S.z], 'file', 'S.txt', 'optimize', false)
The output is pretty much unreadable, being almost 2 megabytes long. It will completely fail at conveying to you that
x = ((n-e)*d^2+(-n^2+(-m+e)*n+m*e+(-p+g)*z+(l-c)*b+(p-g)*f+a-h)*d+n^2*m+(-m*e+(-o+f)*z+k*l-b*l+o*p-f*p+h-j)*n+((o-f)*z-k*l+b*l-o*p+f*p-h+j)*e-((-p+g)*z+(l-c)*b+(p-g)*f+a-h)*m)/((l-c)*d+n*(k-b)+(-k+b)*e-m*(l-c))
where z is the pair of solutions to a long quadratic -- something that can be mechanically generated but you lose the readability.
In theory you should be able to get something more readable by using subexpr() with the results such as S.x, but in practice it takes a long long long time to finish.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!