Problem in output. Output Truncated. Text exceeds maximum line length of 25,000 characters for Command Window display

조회 수: 42 (최근 30일)
I am facing a problem " Output truncated. Text exceeds maximum line length of 25,000 characters for Command Window display.." The code I am working with is :
syms x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12
m=[3452.4 3452.4 3819.4 2652.4 2652.4 2986.1 2652.4 2652.4 2986.1 1809.9 1809.9 2056.9];
m1=eye(12,12);
for i=1:12
M(i,i)=m(1,i)*m1(i,i);
end
k1xd=106.6; k2xd=106.6; k3xd=106.6; k4xd=106.6;
k1yd=67.9; k2yd=x1*67.9; k3yd=67.9; k4yd=67.9;
k1zd=232.02; k2zd=232.02; k3zd=232.02; k4zd=232.02;
Kd=10^6*[k1xd+k2xd 0 0 -k2xd 0 0 0 0 0 0 0 0;
0 k1yd+k2yd 0 0 -k2yd 0 0 0 0 0 0 0;
0 0 k1zd+k2zd 0 0 -k2zd 0 0 0 0 0 0;
-k2xd 0 0 k2xd+k3xd 0 0 -k3xd 0 0 0 0 0;
0 -k2yd 0 0 k2yd+k3yd 0 0 -k3yd 0 0 0 0;
0 0 -k2zd 0 0 k2zd+k3zd 0 0 -k3zd 0 0 0;
0 0 0 -k3xd 0 0 k3xd+k4xd 0 0 -k4xd 0 0;
0 0 0 0 -k3yd 0 0 k3yd+k4yd 0 0 -k4yd 0;
0 0 0 0 0 -k3zd 0 0 k3zd+k4zd 0 0 -k4zd;
0 0 0 0 0 0 -k4xd 0 0 k4xd 0 0;
0 0 0 0 0 0 0 -k4yd 0 0 k4yd 0;
0 0 0 0 0 0 0 0 -k4zd 0 0 k4zd];
[evecx,evalx]=eig(inv(M)*Kd);
Evx=vpa(evecx)
Evax=vpa(evalx)
How can I solve this problem??
  댓글 수: 4
Steven Lord
Steven Lord 2020년 1월 21일
The general rule of thumb I've found on Google is that one single-spaced page of text contains about 3000 characters. So your expression, printed out, would take at least eight pages.
What you are hoping / planning to do with the result of that expression? That may help us determine how you can achieve your goal without trying to display such a long expression.
Swagato Das
Swagato Das 2020년 1월 21일
Surely Sir. I want to find an objective function equation using the Evx. I will use that objective function for an optimization problem to find the unknown value of x1. Hence in the next stage I may have to go for inverse of Evx also. Is there any way to shorten the long expression? Because the result shows a large number after decimal points. Also the longer terms I need can be in terms of powers of 10. If there is any method, please suggest.
Thanks in advance

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

채택된 답변

Sindar
Sindar 2020년 1월 20일
Instead of displaying the results and copying, print them directly to a file. The best format depends on how you will be working with the data later, but CSV is often a good choice (most everything can read it).
Evx=vpa(evecx);
Evax=vpa(evalx);
writematrix(Evx,'Evx.csv')
writematrix(Evax,'Evax.csv')
Then, you will have your data saved in the files (in your current directory)
  댓글 수: 6
Sindar
Sindar 2020년 1월 20일
Whoops, my bad. I somehow didn't process that you were trying to print a symbolic expression. In that case, you just want text:
Evx=vpa(evecx);
Evax=vpa(evalx);
my_stream = fopen('Evx.txt','w');
fprintf(my_stream,'%s',Evx);
fclose(my_stream);
my_stream_a = fopen('Evax.txt','w');
fprintf(my_stream,'%s',Evax);
fclose(my_stream_a);

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2020년 1월 21일
You need a function similar to the below in order to write the symbolic expression to a file for further processing.
Note that the result will be in MuPAD expressions, not in MATLAB expressions. There will be differences in matters such as how matrices are represented, and how sqrt(-1) is represented.
function symwrite(expression, filename)
feval(symengine, '_assign', 'TemporaryName', expression);
cmd = sprintf('fid := fopen("%s", Write, Text); fprint(fid, TemporaryName); fclose(fid);', filename);
evalin(symengine, cmd);
Note:
I give this code to you as a deliberate exercise in futility. It will do what you ask, presenting you with a readable version of your long expressions. You will almost certainly find that having the readable version of the long expressions is useless to you. However you are unlikely to believe any of us on that point until you have seen for yourself just how useless having the full expression is.
  댓글 수: 1
Swagato Das
Swagato Das 2020년 1월 21일
Thank you sir. Yes its true that the expression is too large and I am getting the imaginary numbers. The code it self is coming in like 304 pages of MS Word. Think I will have to find another way. Thanks for the suggestions.

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by