Odd (\\\r\n) output from symbolic multiplication
6 views (last 30 days)
So i'm doing some symbolic multiplication and the resulting expression output is quite long. However it includes one part of odd symbolics, namely: \\\r\n mixed inbetween the rest of the syms variables. I understand this is a line changing command but how can I remove this from the output? It is important since I need to compare if this symbolic output is equal to another expression.
Walter Roberson on 29 Apr 2017
The extra characters used on OS-X and Linux are \n\n rather than \r\n .
The extra characters only affects default display. It does not affect char() of the symbolic expression.
Note that both the default display and char() of the symbolic expression run the risk of:
Output truncated. Text exceeds maximum line length for Command Window display.
You can get around this by stepping into MuPAD:
feval(symengine, '_assign', 'TemporaryName', NameOfYourSymbolicVariable);
evalin(symengine, 'write(Text, "NameOfTheOutputFile.txt", TemporaryName)')
then NameOfTheOutputFile.txt will contain the full text.
By the way: the output file will be written into whichever directory was your current directory at the time you did the first your first symbolic command in this session (or, if you have done "clear all", then the current directory at the time of your first symbolic command since then.) You can give an absolute path for certainty.
More Answers (2)
John Chilleri on 28 Apr 2017
Edited: John Chilleri on 28 Apr 2017
If it's just a one-timer, you can identify where it is and remove it by:
expr = [expr(1:before) expr(after:end)];
If this will be encountered multiple times, then I would create a function to search strings and remove it, for example:
function str = rm_garbage(string)
n = length(string);
for i = 6:n
str = [string(1:i-6) string(i+1:end)];
Running this with an arbitrary string produces:
where you can see the '\\\r\n' has been removed.
Hope this helps!