MATLAB *sometimes* prints non-ASCII characters in the command window

4 views (last 30 days)
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.

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!