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)
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
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.
Jose Lopes
Jose Lopes on 18 Jan 2016
Edited: Geoff Hayes on 19 Jan 2016
Hi Geoff, I type on the command window the following code:
>> e1=sym('a=(b-x)*(c-x)+(d-y)*(e-y)+(f-z)*(g-z)')
e1 =
a == (b - x)*(c - x) + (d - y)*(e - y) + (f - z)*(g - z)
>> e2=sym('j=(k-x)*(l-x)+(m-y)*(n-y)+(o-z)*(p-z)')
e2 =
j == (k - x)*(l - x) + (m - y)*(n - y) + (o - z)*(p - z)
>> e3=sym('h=(b-x)*(l-x)+(d-y)*(n-y)+(f-z)*(p-z)')
e3 =
h == (b - x)*(l - x) + (d - y)*(n - y) + (f - z)*(p - z)
>> S=solve(e1,e2,e3)
S =
x: [2x1 sym]
y: [2x1 sym]
z: [2x1 sym]
>> S.x
ans =
... Output truncated. Text exceeds maximum line length of 25,000 characters for Command Window display.
>> S.y
ans =
... Output truncated. Text exceeds maximum line length of 25,000 characters for Command Window display.
>> S.z
... Output truncated. Text exceeds maximum line length of 25,000 characters for Command Window display.
Tanks in advance!

Sign in to comment.

Answers (2)

Walter Roberson
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.
  1 Comment
Jose Lopes
Jose Lopes on 18 Jan 2016
Tanks for your quick reply, I copied and pasted code feval(symengine, 'write', 'Text', 'YourFile.txt', S.x) after my code, and returns this error: >> feval(symengine, 'write', 'Text', 'YourFile.txt', S.x) Error using mupadengine/feval (line 163) The argument is invalid.
When I wrote matlabfunction(S.x, 'file', 'YourFile.txt', 'Optimize', false) returns me a file but with different symbolic aspects as you said. And and something must be wrong on this 'YourFile.txt' because it should return me two results for x, y, z; like x and - x; y and -y; z and -z.

Sign in to comment.


Olatunji Omisore
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
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.

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!