Output truncated. Text exceeds maximum line length for Command Window display. How to solve?

I have a problem that when I tried to display an answer, I got this message (Output truncated. Text exceeds maximum line length for Command Window display). I know that this is because the answer is too long.
My problem exactly is:
I need to do further processing on the result of f3Up. Exactly, I need to do two things:
1) Replace y1 to be y(1), then do the same thing for y2, y3, ... y10.
2) Replace the multiplication * to be .* and the same for / and ^ to make an element wise process.
I used to display the result, copy it, paste in a new file and then use the command (Replace) to do these two modifications I mentioned above. Now, I cannot display the full result, so I cannot do these modifications.
Can anyone help me with that.
I am using Matlab 2018a and this is an example of f3Up after shortening and deleting a lot of terms just to see what I want to do.
f3Up =(y1*cos((4014731262101775*t)/17592186044416)+5886768972981423*(((110680464442257306357*(44*pi)/5))/36893488147419103232000000 - sin... Output truncated. Text exceeds maximum line length for Command Window display.
Thanks in advance.

1 Comment

I would also like to point out that such lengthy expressions can sometimes be avoided by ensuring the use of symbolic calculations throughout.
syms x
yNotSoNice = diff(sqrt(2*pi) * x^2, x)
yNotSoNice = 
yNice = diff(sqrt(2*sym(pi)) * x^2, x)
yNice = 
Best wishes,
Harald

Sign in to comment.

 Accepted Answer

The only options I can think of are:
f3Up = simplify(f3Up, 'Steps',20);
f3Up = vpa(f3Up, 5)
The first will do its best to simplify the function, by collecting terms and other operations, and the second replaces the long fractions by truncated decimal fractions, without losing any internal precision.

7 Comments

Thank you Star for your reply.
When I tried the first command, I got this:
Error using mupadmex
Internal error with symbolic engine. Quit and restart MATLAB.
Error in mupadengine/evalin (line 123)
[res,status] = mupadmex(statement,output_type{:});
Error in mupadengine/feval (line 182)
[S,err] = evalin(engine,stmt,'message');
Error in sym/simplify (line 66)
rSym = feval(symengine, 'simplify', s,...
I restarted Matlab several times without any change. The same result appears again and again!
I tried the second line ALONE, and I got a complete result. My question is:
Can I use the second command (vpa) ONLY? Is this a correct way to solve the problem?
My pleasure.
You can use the second (the vpa call) only, without first using simplify.
I have no idea what crashed the simplify call.
While I am thinking about it, do not do either of these if you want to use ‘f3Up’ as a numeric (not symbolic) routine:
  • 1) Replace y1 to be y(1), then do the same thing for y2, y3, ... y10.
  • 2) Replace the multiplication * to be .* and the same for / and ^ to make an element wise process.
Use the matlabFunction (link) function to do the conversion. It will produce an anonymous function for ‘f3Up’, that you can then use in your numeric (not symbolic) code. Just call it as a function, and use the result in your other calculations.
Did you install the r2018a patch yet to deal with the crashes of symbolic toolbox after the April 2018 Creator's Update for windows 10?
I considered that as a cause of the crash, too. However, OP apparently had it working before.
My guess is that any ‘re-formatting’ OP did of ‘f3Up’ may have caused the crash. It is best to simplify first and re-format later.
Alternatively, ‘f3Up’ may be more than simplify can deal with.
We do not know when the Update got installed. Also, the details of the cause of the crash still seem a bit vague: although it happened upon first toolbox use in nearly all the cases I saw, I think I saw one or two where very simple use of the toolbox did not lead to the crash.
Thank you very much. I appreciate your help. Your suggestion solved the problem.
Hi ! Did you use what option? the first ou second?

Sign in to comment.

More Answers (1)

In a couple of releases, there was a bug where \r and \n characters could end up in the displayed output. There was a work-around for that, and there is a possibility that it might also affect the point at which output is truncated like you are observing.
Note, though, that the truncated bit is only for display purposes, and does not affect what is stored, so you should be able to store the results to a variable and manipulate it -- just don't use the copy/paste workflow (consider using matlabFunction or subs instead). There is also a way to get the symbolic engine to write out the MuPAD representation of an expression to a text file.
Workaround
Increase the value of the parameter TEXTWIDTH by using this command.
evalin(symengine, "TEXTWIDTH := 2^31-1");

Products

Release

R2018a

Community Treasure Hunt

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

Start Hunting!