Overloaded function causes Matlab to hang
이전 댓글 표시
I needed to compile some code in an old version of Matlab for a customer and one builtin function wasn't supported in 2014b and, since it's a trivial function, I wrote something with same name that would do the same task. I thought I may as well keep it in the main code so wrote it such that it would use the builtin in later Matlab. It worked fine in 2014b and 2018b when I tested it, albeit with warning about same name as a builtin when run in 2018b.
But then I found out that with it on the path, later versions of Matlab won't even launch, they give the warning during Initializing and then hang. I tested this in 2018b and 2020a. Can someone advise why this might be?
Here's the code:
function TF = startsWith(str,pattern,~,ignoreCase)
% Temporary overload of builtin startsWith so that command can be used in
% compiled Matlab 2014b code
if nargin < 4
ignoreCase = false;
end
if ~verLessThan('matlab','9.1') % 2016b
TF = builtin('startsWith',str,pattern,'IgnoreCase',ignoreCase); % call builtin
else
str = str(1:min([length(str), length(pattern)]));
if ignoreCase
str = lower(str);
pattern = lower(pattern);
end
TF = isequal(str,pattern);
end
What did I do wrong?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!