MATLAB *sometimes* prints non-ASCII characters in the command window
7 views (last 30 days)
Show older comments
I have noticed a strange quirk where MATLAB sometimes prints non-ASCII characters in the command window. Specifically, the multiplication sign used to denote array size can be lower case "x" (ASCII code 120) or extended character 215. The latter looks very similar to the former in the command window and some text editors, but the extended character looks very different in LaTeX. I noticed this problem when copying part of the command window (or the diary function) to a LaTeX document: all arrays sizes in an object display are messed up, but direct display with the whos command works as expected. Here's a quick example.
classdef example
properties
Array = rand(100,1);
end
methods
function object=example()
Q=evalc('disp(object)');
fprintf('Object display: ');
scanResult(Q);
Q=evalc('disp(object.Array)');
fprintf('Array display : ');
scanResult(Q);
end
end
end
function scanResult(buffer)
value=double(buffer);
index=find(value > 127);
if isempty(index)
fprintf('no extended characters');
else
N=numel(index);
fprintf('%d extended characters ',N);
for n=1:N
k=index(n);
fprintf('[%d -> %c] ',value(k),buffer(k));
end
end
fprintf('\n');
end
For MATLAB 2019b and 2020a on a Mac, there is one extended character in the object display and none in the array display.
0 Comments
Answers (0)
See Also
Categories
Find more on Environment and Settings 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!