text2im

Formatted documentation for the text2im function.

Generate an image from text (white text on black background).

Contents

Description

This function allows you to convert text to an image. There are several fonts you can pick, each with their own character size.
The list of included characters is based on a relatively arbitrary selection from three Wikipedia pages: general characters, newline characters, and Syntax

imtext=text2im(text)
imtext=text2im(text,font)

Output arguments

imtext A char array containing the text image. The size is dependent on the font.

Input arguments

text The text to be converted can be supplied as char, string, or cellstr. Which characters are allowed is determined by the font. However, all fonts contain the printable and blank characters below 127. Any non-standard newline characters are ignored (i.e. LF/CR/CRLF are parsed as newline). Non-scalar inputs (or non-row vector inputs in the case of char) are allowed, but might not return the desired result.
font Font name as char array. Which fonts are available is dictated by the internal text2im_load_database function. See the table below for more details and the options.

Fonts

Font ID Description and license Character size
'cmu_typewriter_text' This typeface contains 365 characters. This is a public domain typeface. [link] size=90x55
'cmu_concrete' This typeface contains 364 characters. This is a public domain typeface. [link] size=90x75
'ascii' This typeface contains only 94 characters (all printable chars below 127). This typeface was previously published in the text2im() (published on the FileExchange by Tobias Kiessling). [link] size=20x18
'droid_sans_mono' This typeface contains 411 characters and has an Apache License (Version 2.0). [link] size=95x51
'ibm_plex_mono' This typeface contains 376 characters and has an SIL Open Font License. [link] size=95x51
'liberation_mono' This typeface contains 415 characters and has a GNU General Public License. [link] size=95x51
'monoid' This typeface contains 398 characters and has an MIT License. [link] size=95x51

Compatibility, version info, and licence

Compatibility considerations:

Test suite result Windows XP/7/10 Ubuntu 20.04 LTS MacOS 10.15 Catalina
Matlab R2021a W10 : Pass
Matlab R2020b W10 : Pass
Matlab R2020a W10 : Pass
Matlab R2018a W10 : Pass Pass
Matlab R2015a W10 : Pass Pass
Matlab R2013b W10 : Pass
Matlab R2012b W10 : Pass
Matlab R2011a W10 : Pass Pass
Matlab R2010b Pass
Matlab R2010a W7 : Pass
Matlab R2007b W10 : Pass
Matlab 7.1 (R14SP3) XP : Pass
Matlab 6.5 (R13) W10 : Pass
Octave 6.2.0 W10 : Pass
Octave 5.2.0 W10 : Pass Pass
Octave 4.4.1 W10 : Pass Pass

Version: 1.1.0
Date:    2021-05-19
Author:  H.J. Wisselink
Licence: CC by-nc-sa 4.0 ( https://creativecommons.org/licenses/by-nc-sa/4.0 )
Email = 'h_j_wisselink*alumnus_utwente_nl';
Real_email = regexprep(Email,{'*','_'},{'@','.'})

Test suite

This tester is included so you can test if your own modifications would introduce any bugs. These tests form the basis for the compatibility table above.

Note that some of the functions in this tester might be different from the functions included in the actual function. Usually this is done to allow triggering of certain errors.

To save space, the tester function below was minified. The full tester function (including all comments) can be found here.

% Compare the output to pre-computed hashes to test exact equivalence
%
% Pass:    passes all tests
% Partial: [no partial passing condition]
% Fail:    fails any test
%
function v000=aaa___text2im___test(varargin),v000='pass';if nargin==0,v001=false;else,v001=true;
end,if v001,v002='No';else,v002 = questdlg('Test GUI?','','Yes','No','Yes');end,if strcmp(v002,...
'Yes'),v003=true;v004=text2im_load_database('ascii',v003,'trigger GUI');else,v003=true;v004=...
text2im_load_database('ascii',v003);end,v005='The quick brown fox jumped over the lazy dog.';
v006={ 'cmu_typewriter_text','F359E6752670A03B4B80BF9E2FD2FBD9';'cmu_concrete',...
'E93A0D0F023D32DBF3D7A2555D78B825';'ascii','A9D394C668F29F293477DBBDCC0E7877';'droid_sans_mono',...
'262172A9734A48009EAB2E7ACB8D20BD';'ibm_plex_mono','353FA726802F4E99A76BB8FCFC50ECCE';
'liberation_mono','2AE74A75F3F8A93B7021E44F9B96C50F';'monoid',...
'F96E8394C5AFB2412A123D3D05E7DA0E'};v007=size(v006,1);if ~v001,figure(1),clf(1),subplot(v007+1,...
1,1),imshow(text2im(v005)),title('default font'),end,for v008=1:v007,v009=text2im(v005,...
v006{v008,1});v010=ComputeNonCryptHash(v009,128,'-v2');if ~strcmp(v010,v006{v008,2}),...
error('hash of generated image didn''t match hash in library'),end,if ~v001,subplot(v007+1,1,...
v008+1),imshow(v009),title(strrep(v006{v008,1},'_','\_')),end,end,v011=[9 32 160 5760 8192:8202 ...
8239 8287];v012=[10 11 12 13 133 8232 8233];v013=[173 8203 8204 8205 8288];v014=...
unicode_to_char([v011 v012 v013]);try v009=text2im(v014);v010=ComputeNonCryptHash(v009,128,...
'-v2');if ~strcmp(v010,'5A61900CFEC38271667B13E7C768D652'),error('hash comparison failed');end,...
catch,if nargout>0,v000='fail';return,else,error('UTF-8 handling failed'),end,end,try v009=...
text2im({'This will be two lines of the default font.',v005});v010=ComputeNonCryptHash(v009,128,...
'-v2');if ~strcmp(v010,'0EAAFD74F57FE4735F318D4B9A079656'),error('hash comparison failed');end,...
catch,if nargout>0,v000='fail';return,else,error('multiline failed'),end,end,...
disp('test completed'),if nargout==0,clear,end,end
function v000=AddMissing(v001,v000),v002=fieldnames(v001);v003=fieldnames(v000);for v004=...
find(~ismember(v002,v003)).',v005=v002{v004};v000.(v005)=v001.(v005);end,end
function [v000,v001,v002]=ComputeNonCryptHash_parse_inputs(varargin),v000=true;v002=struct;
persistent v003,if isempty(v003),v003=struct;v003.HashLength=256;v003.Version=2;
v003.VersionFlag='-v2';v003.SkipInputParse=false;v003.isSaltCall=false;v004=struct;
v003.print_to_con=true;v004.print_to_con=v003.print_to_con;v003.print_to_fid=[];
v004.print_to_fid=v003.print_to_fid;v003.print_to_obj=[];v004.print_to_obj=v003.print_to_obj;
v003.print_to_fcn=[];v004.print_to_fcn=v003.print_to_fcn;v003.print_2__default_options=v004;
v003.print_2__options=validate_print_to__options(v004);end,if nargin==0,v001=...
ComputeNonCryptHash_DefaultsByVersion(v003);return,end,if nargin==1,switch class(varargin{1}),...
case {'char','string'},v001=AddMissing(v003,struct('VersionFlag',char(varargin{1})));case ...
'struct',v001=AddMissing(v003,varargin{1});otherwise,v001=AddMissing(v003,struct('HashLength',...
varargin{1}));end,[v001,v002,v000]=ComputeNonCryptHash_parse_inputs__ValidateInputs(v001);if ...
v000,v001=ComputeNonCryptHash_DefaultsByVersion(v001);end,return,end,try [v001,v002,v005]=...
ComputeNonCryptHash_parse_inputs__UnwindToStruct( struct,v002,~v000,varargin{:});v000=~v005;
catch,v002.identifier='HJW:ComputeNonCryptHash:InputFail';v002.message=...
'Input parsing failed. Maybe a parameter has been entered twice.';v000=false;end,if ~v000,...
return,else ,v001=AddMissing(v003,v001);end,[v001,v002,v000]=...
ComputeNonCryptHash_parse_inputs__ValidateInputs(v001);if v000,v001=...
ComputeNonCryptHash_DefaultsByVersion(v001);end,end
function [v000,v001,v002]=ComputeNonCryptHash_parse_inputs__ValidateInputs(v000),v002=true;v001=...
struct;try v003=str2double(v000.VersionFlag(3:end));if isnan(v003) || round(v003)~=v003 || ...
v003>2,error('trigger');end,v000.Version=v003;catch,v001.identifier=...
'HJW:ComputeNonCryptHash:InputIncorrect';v001.message=...
'Version input incorrect. Must be ''-v1'', ''-v2''.';v002=false;return,end,v004=v000.HashLength;
if numel(v004)~=1 || ~isnumeric(v004) || mod(v004,16)~=0 || v004<16,v001.identifier=...
'HJW:ComputeNonCryptHash:InputIncorrect';v001.message=...
'Second input (hash length) must be a multiple of 16.';v002=false;return,end,for v005=...
fieldnames(v000.print_2__default_options),if ~isequal(v000.(v005{1}),...
v000.print_2__default_options.(v005{1})),[v006,v001]=validate_print_to__options(v000);if ...
isempty(v006),v001.identifier='HJW:ComputeNonCryptHash:PrintToIncorrect';v002=false;return,end,...
v000.print_2__options=v006;break,end,end,end
function [v000,v001,v002]=ComputeNonCryptHash_parse_inputs__UnwindToStruct(v000,v001,v002,...
varargin),if v002 || numel(varargin)==0,return,end,v003=varargin{1};if isa(v003,'struct'),v004=...
fieldnames(v000);v005=fieldnames(v003);v006=unique([v004;v005]);if numel(v004)+numel(v005) ~= ...
numel(v006),v002=true;return,end,v000=AddMissing(v000,v003);varargin(1)=[];elseif isa(v003,...
'char') || isa(v003,'string'),try if isa(v003,'string'),v003=char(v003);end,if strcmpi('-v',...
v003(1:2)),if isfield(v000,'VersionFlag'),error('trigger'),end,v000.VersionFlag=v003;
varargin(1)=[];else,if isfield(v000,v003),error('trigger'),end,v000.(v003)=varargin{2};
varargin(1:2)=[];end,catch,v002=true;return,end,else,if isfield(v000,'HashLength'),v002=true;
return,end,v000.HashLength=v003;varargin(1)=[];end,[v000,v001,v002]=...
ComputeNonCryptHash_parse_inputs__UnwindToStruct(v000,v001,v002,varargin{:});end
function v004=get_MatFileFlag,persistent v000,if isempty(v000),v001=exist('OCTAVE_VERSION', ...
'builtin');v002=version;v003=min([numel(v002) strfind(v002,'.')]);v002=...
str2double(v002(1:(v003-1)));if v001 || v002<7,v000='-mat';else,v000='-v6';end,end,v004=v000;end
function [v000,v001]=GetWritableFolder(varargin),[v002,v003,v004]=...
GetWritableFolder_parse_inputs(varargin{:});if ~v002,rethrow(v004),else,[v005,v006,v007]=...
deal(v003.ForceStatus,v003.ErrorOnNotFound,v003.root_folder_list);end,v007{end}=pwd;if v005,...
v001=v005;v000=fullfile(v007{v001},'PersistentFolder');try if ~exist(v000,'dir'),mkdir(v000);
end,catch,end,return,end,v001=1;v000=v007{v001};try if ~exist(v000,'dir'),mkdir(v000);end,catch,...
end,if ~TestFolderWritePermission(v000),v001=2;v000=v007{v001};try if ~exist(v000,'dir'),...
mkdir(v000);end,catch,end,if ~TestFolderWritePermission(v000),v001=3;v000=v007{v001};end,end,...
v000=fullfile(v000,'PersistentFolder');try if ~exist(v000,'dir'),mkdir(v000);end,catch,end,if ...
~TestFolderWritePermission(v000),if v006,error('HJW:GetWritableFolder:NoWritableFolder',...
'This function was unable to find a folder with write permissions.'),else,v001=0;v000='';end,...
end,end
function [v000,v001]=get_trace(v002,v001),if nargin==0,v002=1;end,if nargin<2, v001=dbstack;end,...
v001(1:v002)=[];if ~isfield(v001,'file'),for v003=1:numel(v001),v004=v001(v003).name;if ...
strcmp(v004(end),')'),v005=strfind(v004,'(');v006=v004( (v005(end)+1):(end-1) );v007=...
v004(1:(v005(end)-2));else,v007=v004;[v008,v006]=fileparts(v004);end,[v008,v001(v003).file]=...
fileparts(v007);v001(v003).name=v006;end,end,persistent v009,if isempty(v009),v009=...
exist('OCTAVE_VERSION','builtin');end,if v009,for v003=1:numel(v001),[v008,v001(v003).file]=...
fileparts(v001(v003).file);end,end,v010=v001;v011='>';v000=cell(1,numel(v010)-1);for v003=...
1:numel(v010),[v012,v010(v003).file,v013]=fileparts(v010(v003).file);if v003==numel(v010),...
v010(v003).file='';end,if strcmp(v010(v003).file,v010(v003).name),v010(v003).file='';end,if ...
~isempty(v010(v003).file),v010(v003).file=[v010(v003).file '>'];end,v000{v003}=...
sprintf('%c In %s%s (line %d)\n',v011,v010(v003).file,v010(v003).name,v010(v003).line);v011=' ';
end,v000=horzcat(v000{:});end
function error_(v001,varargin),persistent v000,if isempty(v000),v000=func2str(@error_);end,if ...
isempty(v001),v001=struct;end,v001=parse_warning_error_redirect_options(v001);[v002,v003,v004,...
v005]=parse_warning_error_redirect_inputs(varargin{:});v006=struct('identifier',v002,'message',...
v003,'stack',v004);if v001.boolean.obj,v007=v003;while v007(end)==10,v007(end)='';end,if ...
any(v007==10),v007=char2cellstr(['Error: ' v007]);else,v007=['Error: ' v007];end,for v008=...
v001.obj(:).',try set(v008,'String',v007);catch,end,end,end,if v001.boolean.fid,for v009=...
v001.fid(:).',try fprintf(v009,'Error: %s\n%s',v003,v005);catch,end,end,end,if v001.boolean.fcn,...
if ismember(v000,{v004.name}),error('prevent recursion'),end,for v010=v001.fcn(:).',if ...
isfield(v010,'data'),try feval(v010.h,'error',v006,v010.data);catch,end,else,try feval(v010.h,...
'error',v006);catch,end,end,end,end,rethrow(v006),end
function [v000,v001,v002]=GetWritableFolder_parse_inputs(varargin),v000=false;v001=struct;v002=...
struct('identifier','','message','');persistent v003,if isempty(v003),v003.ForceStatus=false;
v003.ErrorOnNotFound=false;v003.root_folder_list={ GetPseudoAddonpath;fullfile(tempdir,...
'MATLAB');''};end,if nargin==2,v001=v003;v000=true;return,end,v004= nargin ==1 && ...
isa(varargin{1},'struct');v005=mod(nargin,2)==0 && all( cellfun('isclass',varargin(1:2:end),...
'char' ) | cellfun('isclass',varargin(1:2:end),'string') );if ~( v004 || v005 ),v002.message=...
['The input is expected to be either a struct, ',char(10),'or consist of Name,Value pairs.'];
v002.identifier='HJW:GetWritableFolder:incorrect_input_options';return,end,if v005,for v006=...
1:2:numel(varargin),try v001.(varargin{v006})=varargin{v006+1};catch,v002.message=...
'Parsing of Name,Value pairs failed.';v002.identifier=...
'HJW:GetWritableFolder:incorrect_input_NameValue';return,end,end,else,v001=varargin{1};end,v007=...
fieldnames(v001);for v008=1:numel(v007),v009=v007{v008};v010=v001.(v009);v002.identifier=...
['HJW:GetWritableFolder:incorrect_input_opt_' lower(v009)];switch v009,case 'ForceStatus',try ...
if ~isa(v003.root_folder_list{v010},'char'),...
error('the indexing must have failed, trigger error'),end,catch,v002.message=...
sprintf('Invalid input: expected a scalar integer between 1 and %d.',...
numel(v003.root_folder_list));return,end,case 'ErrorOnNotFound',[v011,v001.ErrorOnNotFound]=...
test_if_scalar_logical(v010);if ~v011,v002.message=...
'ErrorOnNotFound should be either true or false.';return,end,otherwise,v002.message=...
sprintf('Name,Value pair not recognized: %s.',v009);v002.identifier=...
'HJW:GetWritableFolder:incorrect_input_NameValue';return,end,end,v007=fieldnames(v003);for v008=...
1:numel(v007),if ~isfield(v001,v007(v008)),v001.(v007{v008})=v003.(v007{v008});end,end,v000=...
true;v002=[];end
function v002=GetPseudoAddonpath,if ispc,[v000,v001]=system('echo %APPDATA%');v001(v001<14)='';
v002=fullfile(v001,'MathWorks','MATLAB Add-Ons');else,[v000,v003]=system('echo $HOME');
v003(v003<14)='';v002=fullfile(v003,'Documents','MATLAB','Add-Ons');end,end
function v000=ifversion(v001,v002,v003,v004,v005),persistent v006 v007 v008,if isempty(v006),...
v008=exist('OCTAVE_VERSION', 'builtin');v006=version;v009=strfind(v006,'.');if numel(v009)~=1,...
v006(v009(2):end)='';v009=v009(1);end,v006=[str2double(v006(1:(v009-1))) ...
str2double(v006((v009+1):end))];v006=v006(1)+v006(2)/100;v006=round(100*v006);v007={ 'R13' 605;
'R13SP1' 605;'R13SP2' 605;'R14' 700;'R14SP1' 700;'R14SP2' 700;'R14SP3' 701;'R2006a' 702;
'R2006b' 703;'R2007a' 704;'R2007b' 705;'R2008a' 706;'R2008b' 707;'R2009a' 708;'R2009b' 709;
'R2010a' 710;'R2010b' 711;'R2011a' 712;'R2011b' 713;'R2012a' 714;'R2012b' 800;'R2013a' 801;
'R2013b' 802;'R2014a' 803;'R2014b' 804;'R2015a' 805;'R2015b' 806;'R2016a' 900;'R2016b' 901;
'R2017a' 902;'R2017b' 903;'R2018a' 904;'R2018b' 905;'R2019a' 906;'R2019b' 907;'R2020a' 908;
'R2020b' 909;'R2021a' 910};end,if v008,if nargin==2,warning('HJW:ifversion:NoOctaveTest',...
['No version test for Octave was provided.',char(10),...
'This function might return an unexpected outcome.']),if isnumeric(v002),v010=...
0.1*v002+0.9*fix(v002);v010=round(100*v010);else,v011=ismember(v007(:,1),v002);if sum(v011)~=1,...
warning('HJW:ifversion:NotInDict','The requested version is not in the hard-coded list.'),v000=...
NaN;return,else,v010=v007{v011,2};end,end,elseif nargin==4,[v001,v010]=deal(v003,v004);v010=...
0.1*v010+0.9*fix(v010);v010=round(100*v010);else,[v001,v010]=deal(v004,v005);v010=...
0.1*v010+0.9*fix(v010);v010=round(100*v010);end,else,if isnumeric(v002),v010=...
0.1*v002+0.9*fix(v002);v010=round(100*v010);else,v011=ismember(v007(:,1),v002);if sum(v011)~=1,...
warning('HJW:ifversion:NotInDict','The requested version is not in the hard-coded list.'),v000=...
NaN;return,else,v010=v007{v011,2};end,end,end,switch v001,case '==', v000= v006 == v010;case ...
'<' , v000= v006 < v010;case '<=', v000= v006 <= v010;case '>' , v000= v006 > v010;case '>=', ...
v000= v006 >= v010;end,end
function v000=bsxfun_plus(v001,v002),try v000=v001+v002;catch,try v000=bsxfun(@plus,v001,v002);
catch,v003=size(v001); v004=size(v002);v001=repmat(v001,max(1,v004./v003)); v002=repmat(v002,...
max(1,v003./v004));v000=v001+v002;end,end,end
function [v000,v001,v002,v003]=parse_warning_error_redirect_inputs(varargin),if nargin==1,if ...
isa(varargin{1},'struct') || isa(varargin{1},'MException'),v004=varargin{1};try v002=v004.stack;
v003=get_trace(0,v002);catch,[v003,v002]=get_trace(3);end,v000=v004.identifier;v001=...
v004.message;v005=...
'Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback(';if ...
isa(v004,'struct') && numel(v001)>numel(v005) && strcmp(v005,v001(1:numel(v005))),...
v001(1:find(v001==10,1))='';end,else,[v003,v002]=get_trace(3);[v000,v001]=deal('',varargin{1});
end,else,[v003,v002]=get_trace(3);if ~isempty(strfind(varargin{1},'%')),v000='';v006=...
varargin(2:end);v001=sprintf(varargin{1},v006{:});else,v000=varargin{1};v001=varargin{2};if ...
nargin>3,v006=varargin(3:end);v001=sprintf(v001,v006{:});end,end,end,end
function v000=cast_to_uint16_vector__cell(v000,v001),v002=size(v000).';v000=v000(:);for v003=...
1:numel(v000),if numel(v000{v003})==0,v004=double(class(v000{v003})');v000{v003}=uint16([0;v004;
size(v000{v003})']);continue,end,switch class(v000{v003}),case {'double','single'},v000{v003}=...
cast_to_uint16_vector__floats(v000{v003});case 'logical',v000{v003}=...
cast_to_uint16_vector__logical(v000{v003});case {'uint8','uint16','uint32','uint64','int8',...
'int16','int32','int64'},v000{v003}=cast_to_uint16_vector__integer(v000{v003},v001);case 'char',...
v000{v003}=cast_to_uint16_vector__char(v000{v003},v001);case 'string',v000{v003}=...
cast_to_uint16_vector__string(v000{v003},v001);case 'cell',v000{v003}=...
cast_to_uint16_vector__cell(v000{v003},v001);case 'struct',v000{v003}=...
cast_to_uint16_vector__struct(v000{v003},v001);case {'gpuArray','tall'},v000{v003}=...
cast_to_uint16_vector__cell({gather(v000{v003})},v001);otherwise,error_(v001.print_to,...
'HJW:cast_to_uint16_vector:nosupport','Unsupported data type in nested variable'),end,end,v000=...
cell2mat(v000);v000=[v000;uint16(mod(v002,2^16))];end
function v000=cast_to_uint16_vector__floats(v000),v001=size(v000).';v002=class(v000);[v003,...
v004]=typecast_double_uint64(double(v000));v005=mod(v003,2^16);v003=v003-v005;v003=v003/2^16;
v004=v004.';v006 =mod(v003,2^16);v003=v003-v006; v003=v003/2^16;v006=v006.';v007 =mod(v003,...
2^16);v003=v003-v007; v003=v003/2^16;v007=v007.';v008 =mod(v003,2^16); v008=v008.';v000=[v008;
v007;v006;v004];v000=uint16(v000(:));v000=[v000;uint16(v002.');uint16(mod(v001,2^16))];end
function v000=cast_to_uint16_vector__logical(v000),v001=size(v000).';v000=v000(:);if ...
mod(numel(v000),16),v000(16*ceil(numel(v000)/16))=0;end,v002=uint16(2.^(15:-1:0))';v000=...
uint16(reshape(v000,16,[]));try v000=v000.*v002;catch,v000=double(v000).*repmat(double(v002),[1 ...
size(v000,2)]);v000=uint16(v000);end,v000=uint16(sum(v000,1)).';v000=[v000;uint16(mod(v001,...
2^16))];end
function v000=cast_to_uint16_vector__struct(v000,v001),v002=size(v000).';v000=v000(:);v003=...
fieldnames(v000);v004=cell(2,numel(v003));for v005=1:numel(v003),v004{1,v005}=v003{v005};v004{2,...
v005}={v000.(v003{v005})};end,v000=cast_to_uint16_vector__cell(v004,v001);v000=[v000;
uint16(mod(v002,2^16))];end
function v000=char2cellstr(v001,v002),v003=isa(v001,'char');v001=int32(v001);if nargin<2,if ...
any(v001==13),v001=PatternReplace(v001,int32([13 10]),int32(-10));v001(v001==13)=-10;end,...
v001(v001==10)=-10;else,for v004=1:numel(v002),v001=PatternReplace(v001,int32(v002{v004}),...
int32(-10));end,end,v005=[0 find(v001==-10) numel(v001)+1];v000=cell(numel(v005)-1,1);for v004=...
1:numel(v000),v006=(v005(v004 )+1);v007=(v005(v004+1)-1);v000{v004}=v001(v006:v007);end,if v003,...
for v004=1:numel(v000),v000{v004}= char(v000{v004});end,else,for v004=1:numel(v000),v000{v004}=...
uint32(v000{v004});end,end,end
function v000=ComputeNonCryptHash(v001,varargin),if nargin<1,...
error('HJW:ComputeNonCryptHash:InputIncorrect','At least 1 input required.'),end,if nargin==2 ...
&& isa(varargin{1},'struct') && varargin{1}.SkipInputParse,v002=varargin{1};else,[v003,v002,...
v004]=ComputeNonCryptHash_parse_inputs(varargin{:});if ~v003,rethrow(v004),end,end,...
v002.print_to=v002.print_2__options;v005=v002.HashLength;v006=v002.Version;try v004=[];v001=...
cast_to_uint16_vector(v001,v002);catch v004;if isempty(v004),v004=lasterror;end,if ...
strcmp(v004.identifier,'MATLAB:nomem'),error_(v002.print_to,v004),else,if isfield(v002,'debug') ...
&& v002.debug,v007=sprintf('\n[original error: %s %s]',v004.identifier,v004.message);else,v007=...
'';end,error_(v002.print_to,'HJW:ComputeNonCryptHash:UnwindFailed',...
['The nested input contains an unsupported data type.' v007]),end,end,if mod(numel(v001),...
v005/16),v008=uint16(1:v005/16).'; v008(1:mod(numel(v001),v005/16))=[];v001=[v001;v008];end,if ...
v006==1,v001=ComputeNonCryptHash_shuffle_uint16(v001);v001=...
ComputeNonCryptHash_uint16_to_logical(v001);v001=xor(v001,reshape(v001,[],16).');else,v001=...
ComputeNonCryptHash_shuffle_uint16(v001);v001=ComputeNonCryptHash_uint16_to_logical(v001);v001=...
circshift_by_col(v001);end,v001=mod(sum(reshape(v001,v005,[]),2),2);v001=...
ComputeNonCryptHash_logical_to_uint16(v001);if v002.isSaltCall,v000=v001;return,end,v001=...
ComputeNonCryptHash_add_salt(v001,v002);v000=ComputeNonCryptHash_dec2hex(v001);v000=...
reshape(v000.',1,[]);end
function v000=cast_to_uint16_vector(v000,v001),if isa(v000,'uint16'),v002='uint16';v003=...
size(v000).';v000=reshape(v000,[],1);v000=[v000;uint16(v002.');uint16(mod(v003,2^16))];return,...
end,v000=cast_to_uint16_vector__cell({v000},v001);v000([end-1 end])=[];end
function v000=cast_to_uint16_vector__integer(v000,v001),v002=size(v000).';v000=v000(:);
persistent v003,if isempty(v003),v003=ifversion('>=','R2010b','Octave','>',0);end,v004=...
class(v000);v005=~v001.cast_int64_double && v003 && v004(end)=='4';if ~v005,if ...
any(abs(double(v000(:)))>2^52),warning_(v001,'HJW:ComputeNonCryptHash:int64rounding',...
['int64 and uint64 will be rounded pre-R2010b, resulting in rounding.',char(10),...
'This will result in a hash that is different from newer releases.']),end,end,if v005,if ...
v004(1)~='u',v006=v000>0;v007=-int64(-inf);v008=uint64(v000+v007+1);v008(v006)=...
uint64(v000(v006))+uint64(v007)+1;v000=v008;end,elseif v004(1)~='u',v000=...
double(v000)-double(eval([v004 '(-inf)']));else,v000=double(v000);end,switch v004(end),case '8',...
if mod(numel(v000),2),v000(end+1)=0;end,v000=reshape(v000,[],2);v000=v000(:,1)*255+v000(:,2);
v000=uint16(v000);case '6',v000=uint16(v000);case '2',v009=floor(v000/2^16);v009=v009.';v010=...
mod(v000,2^16); v010=v010.';v000=[v009;v010];v000=uint16(v000(:));case '4',v011=v000;v012=...
mod(v011,2^16);v011=v011-v012;v011=v011/2^16;v012=v012.';v013=mod(v011,2^16);v011=v011-v013;
v011=v011/2^16;v013=v013.';v010=mod(v011,2^16);v011=v011-v010;v011=v011/2^16;v010=v010.';v009=...
mod(v011,2^16); v009=v009.';v000=[v009;v010;v013;v012];v000=uint16(v000(:));end,v000=[v000;
uint16(v004.');uint16(mod(v002,2^16))];end
function v000=cast_to_uint16_vector__string(v000,v001),if v001.string_to_cellstr,v000=...
cellstr(v000);v000=cast_to_uint16_vector__cell(v000,v001);else,v000=char(v000);v000=...
cast_to_uint16_vector__char(v000,v001);end,end
function v000=cast_to_uint16_vector__char(v000,v001),persistent v002,if isempty(v002),v002 = ...
exist('OCTAVE_VERSION', 'builtin') ~= 0;end,if v002 && v001.re_encode_char,v003 = size(v000,1)==...
numel(v000);if v003,v000=v000.';end,v000=cellstr(v000);for v004=1:numel(v000),v000{v004}=...
unicode_to_char(UTF8_to_unicode(v000{v004},v001.print_to),true);end,v005=cellfun('length',v000);
v006=max(v005);for v004=find(v005<v006),v000{v004}( (numel(v000{v004})+1) : v006)=uint16(' ');
end,v000=cell2mat(v000);if v003,v000=v000.';end,end,v007=size(v000).';v000=v000(:);v000=...
uint16(v000);v000=[v000;uint16(mod(v007,2^16))];end
function v000=parse_warning_error_redirect_options(v000),if ~isfield(v000,'boolean'),...
v000.boolean=struct;end,if ~isfield(v000.boolean,'con') || isempty(v000.boolean.con),...
v000.boolean.con=false;end,if ~isfield(v000.boolean,'fid') || isempty(v000.boolean.fid),...
v000.boolean.fid=isfield(v000,'fid');end,if ~isfield(v000.boolean,'obj') || ...
isempty(v000.boolean.obj),v000.boolean.obj=isfield(v000,'obj');end,if ~isfield(v000.boolean,...
'fcn') || isempty(v000.boolean.fcn),v000.boolean.fcn=isfield(v000,'fcn');end,end
function v000=PatternReplace(v001,v002,v003),v000=v001(:)';if numel(v002)==0,v004=...
false(size(v001));elseif numel(v003)>numel(v002),error('not implemented (padding required)'),...
else,v004=true(size(v001));for v005=1:numel(v002),v006=find(v001==v002(v005));v006=v006-v005+1;
v006(v006<1)=[];v007=false(size(v004));v007(v006)=true;v004= v004 & v007;if ~any(v004),break,...
end,end,end,v006=find(v004);if ~isempty(v006),for v005=1:numel(v003),v000(v006+v005-1)=...
v003(v005);end,if numel(v003)==0,v005=0;end,if numel(v002)>v005,v006=v006(:);v008=...
(v005+1):numel(v002);v009=bsxfun_plus(v006,v008-1);v000(v009(:))=[];end,end,end
function [v000,v001]=test_if_scalar_logical(v001),persistent v002,if isempty(v002),v002={true,...
false;1,0;'on','off';'enable','disable';'enabled','disabled'};try v002(end+1,:)=...
eval('{"on","off"}');catch,end,end,v000=true;try if isa(v001,'char') || isa(v001,'string'),try ...
v001=lower(v001);catch,end,end,for v003=1:size(v002,1),for v004=1:2,if isequal(v001,v002{v003,...
v004}),v001=v002{1,v004};return,end,end,end,if isa(v001,'matlab.lang.OnOffSwitchState'),v001=...
logical(v001);return,end,catch,end,v000=false;end
function v000=ComputeNonCryptHash_add_salt(v000,v001),v002=16*numel(v000);v003=v001;
v003.Version=1; v003.HashLength=v002;v003.SkipInputParse=1; v003.isSaltCall=1;v004=...
ComputeNonCryptHash(v000,v003);v004=ComputeNonCryptHash_shuffle_uint16_inv(v004);if ...
v001.Version>1,v004=v004(end:-1:1);end,v000=mod(double(v000).*double(v004),1+2^16);v000=...
uint16(v000);end
function v000=ComputeNonCryptHash_dec2hex(v001),persistent v002,if isempty(v002),v002=...
upper(dec2hex(0:(-1+2^16),4));end,v001=double(v001)+1;v000=v002(v001,:);end
function v000=circshift_by_col(v000),persistent v001,v002=size(v000);if isempty(v001) || ...
any(size(v001)<v002) || isempty(v001{v002(1),v002(2)}),[v003,v004]=meshgrid(1:size(v000,2),...
1:size(v000,1));v005=mod(v003+v004-2,size(v000,1))+1;v006=sub2ind(size(v000),v005,v003);if ...
prod(v002)<=1000,v001{v002(1),v002(2)}=v006;end,else,v006=v001{v002(1),v002(2)};end,v000=...
v000(v006);end
function v000=TestFolderWritePermission(v001),if ~( isempty(v001) || exist(v001,'dir') ),v000=...
false;return,end,v002='';while isempty(v002) || exist(v002,'file'),[v003,v002]=...
fileparts(tmpname('write_permission_test_','.txt'));v002=fullfile(v001,v002);end,try v004=...
fopen(v002,'w');fprintf(v004,'test');fclose(v004);delete(v002);v000=true;catch,if exist(v002,...
'file'),try delete(v002);catch,end,end,v000=false;end,end
function v000=text2im(v001,v002),if nargin<2,v002='cmu_typewriter_text';end,[v003,v004,v005]=...
text2im_load_database(v002);v006=ifversion('>',0,'Octave','<',0);try v007=cellstr(v001);for ...
v008=1:numel(v007),v009=v007{v008};if v006,v009=UTF16_to_unicode(v009);else,v009=...
UTF8_to_unicode(v009);end,v007{v008}=v009;end,for v008=1:numel(v007),v007{v008}=...
char2cellstr(v007{v008});end,v007=vertcat(v007{:});for v008=1:numel(v007),v007{v008}=...
v007{v008}(ismember(v007{v008},v003));end,v010=cellfun('prodofsize',v007);v011=max(v010);for ...
v008=find(v010<v011).',v007{v008}((end+1):v011)=32;end,v001=cell2mat(v007);if ...
~all(ismember(v001,v005(1,:))),error('invalid char detected'),end,catch,...
error('HJW:text2im:InvalidInput',...
['The input is invalid or contains symbols that are missing in your font.',char(10),...
'(all fonts will have the <127 ASCII characters)']),end,v000=cell2mat(reshape(v004(v001),...
size(v001)));end
function v000=text2im_create_pref_struct(varargin),v000=struct;v001={'CMU Typewriter Text',...
'CMU Concrete','ASCII','Droid Sans Mono','IBM Plex Mono','Liberation Mono','Monoid'};for v002=...
1:numel(v001),v000(v002).name=v001{v002};v000(v002).valid_name=strrep(lower(v000(v002).name),...
' ','_');switch v000(v002).valid_name,case 'cmu_typewriter_text',v000(v002).url=...
['http://web.archive.org/web/20200418101117im_/',...
'https://hjwisselink.nl/FEXsubmissiondata/75021-text2im/',...
'text2im_glyphs_CMU_Typewriter_Text.png'];case 'cmu_concrete',v000(v002).url=...
['http://web.archive.org/web/20200418093550im_/',...
'https://hjwisselink.nl/FEXsubmissiondata/75021-text2im/','text2im_glyphs_CMU_Concrete.png'];
case 'ascii',v000(v002).url=['http://web.archive.org/web/20200418093459im_/',...
'https://hjwisselink.nl/FEXsubmissiondata/75021-text2im/','text2im_glyphs_ASCII.png'];case ...
'droid_sans_mono',v000(v002).url=['http://web.archive.org/web/20200418093741im_/',...
'https://hjwisselink.nl/FEXsubmissiondata/75021-text2im/','text2im_glyphs_Droid_Sans_Mono.png'];
case 'ibm_plex_mono',v000(v002).url=['http://web.archive.org/web/20200418093815im_/',...
'https://hjwisselink.nl/FEXsubmissiondata/75021-text2im/','text2im_glyphs_IBM_Plex_Mono.png'];
case 'liberation_mono',v000(v002).url=['http://web.archive.org/web/20200418093840im_/',...
'https://hjwisselink.nl/FEXsubmissiondata/75021-text2im/','text2im_glyphs_Liberation_Mono.png'];
case 'monoid',v000(v002).url=['http://web.archive.org/web/20200418093903im_/',...
'https://hjwisselink.nl/FEXsubmissiondata/75021-text2im/','text2im_glyphs_Monoid.png'];
otherwise,v000(v002).url=fullfile(tempdir,['text2im_glyphs_',strrep(v001{v002},' ','_'),...
'.png']);end,[v000(v002).printable,v000(v002).glyphs]=text2im__get_glyphs(v000(v002),...
varargin{:});end,end
function v000=ComputeNonCryptHash_logical_to_uint16(v000),if mod(numel(v000),16),...
v000(16*ceil(numel(v000)/16))=0;end,v001=uint16(2.^(15:-1:0))';v000=uint16(reshape(v000,16,[]));
try v000=v000.*v001;catch,v000=double(v000).*repmat(double(v001),[1 size(v000,2)]);v000=...
uint16(v000);end,v000=uint16(sum(v000,1)).';end
function [v000,v001]=text2im__get_glyphs(v002,varargin),if nargin==1,v003=...
text2im__download_IM(v002.url);else,v003=[];end,if isempty(v003),v003=...
text2im__get_IM_from_user(v002);end,v004=bin2dec(char('0'+reshape(v003(1,1:60),20,3)'));v005=...
(v004(1))*ones(1,ceil(v004(3)/32));v006=(v004(2)+1)*ones(1,32);v007=mat2cell(v003(2:end,:),v005,...
v006);v007=v007';v007=v007(1:v004(3));v001=cell(size(v007));v000=zeros(size(v007));v008=max(1,...
v004(1)-17);for v009=1:numel(v007),v001{v009}=v007{v009}(:,2:end);v000(v009)=...
bin2dec(char('0'+v007{v009}(v008:end,1)'));end,end
function v000=ComputeNonCryptHash_shuffle_uint16(v000),v001=65537;v002=479001600;v000 = ...
uint16(mod(double(v000) * v002 , v001));end
function v000=text2im__download_IM(v001),for v002=1:3,try v000=imread(v001);break,catch,v000=[];
end,end,if isempty(v000),v003=v001(46:end);try v000=imread(v003);catch,v000=[];end,end,end
function [v000,v001]=typecast_double_uint64(v002),[v003,v004]=log2(v002);v005 =...
-floor(sign(v002)/2-0.5);v006=v004+1022;v007=abs(v003)*2-1;v000=zeros(size(v002));v000=...
v000+(v005*2^63);v000=v000+(v006*2^52);v000=v000+(v007*2^52);v001=mod(v007*2^52,2^16);v008=...
isinf(v002);v000(v002==0)=0;v000(isnan(v002))=18444492273895866368;v000(v008 & v002>0)=...
9218868437227405312;v000(v008 & v002<0)=18442240474082181120;v001(v002==0)=0;v001(isnan(v002))=...
0;v001(v008)=0;end
function [v000,v001,v002]=text2im_load_database(v003,varargin),persistent v004,if nargin<2,v005=...
false;else,v005=varargin{1};end,if nargin<3,v006=false;else,v006=true;end,if v005,v004=[];end,...
if isempty(v004),v007=fullfile(GetWritableFolder,'FileExchange','text2im','glyph_database.mat');
v008=fileparts(v007);if ~exist(v008,'dir'),mkdir(v008);end,if exist(v007,'file'),v009=...
load(v007);v010=fieldnames(v009);v004=v009.(v010{1});end,if v005,v004=[];end,if isempty(v004),...
if v006,v004=text2im_create_pref_struct(v006);else,v004=text2im_create_pref_struct;end,...
save(v007,var2str(v004),get_MatFileFlag),end,end,if nargin>0,v011={v004.valid_name};v012=...
find(ismember(v011,v003));if isempty(v012),warning('HJW:text2im:IncorrectFontName',...
'Font name doesn''t match any implemented font, reverting to default.'),v012=1;end,else,v012=1;
end,v009=v004(v012);v013=[9 32 160 5760 8192:8202 8239 8287];v014=[10 11 12 13 133 8232 8233];
v015=[173 8203 8204 8205 8288];v016=v009.printable(:)';v001=cell(max(v016),1);v001(v016)=...
v009.glyphs;v001(v013)={false(size(v009.glyphs{1}))};v002=[v016 v013 v014 v015;ones(size(v016)),...
2*ones(size(v013)),3*ones(size(v014)),4*ones(size(v015))];v000=sort([v016 v013]);end
function v000=text2im__get_IM_from_user(v001),v002={'Loading of image failed.','',...
['You can try again or manually download the image ','from the URL below.'],'',...
['Once you have downloaded the png, click the button and locate ','the file.']};v003='menu';if ...
exist('OCTAVE_VERSION', 'builtin'),v003='menubar';end,v004=figure(v003,'none','toolbar','none');
uicontrol('Parent',v004,'style','text','Units','Normalized','Position',[0.15 0.75 0.70 0.15],...
'String',v002);uicontrol('Parent',v004,'style','edit','Units','Normalized','Position',[0.15 0.5 ...
0.70 0.15],'String',v001.url);uicontrol('Parent',v004,'style','pushbutton','Units','Normalized',...
'Position',[0.15 0.15 0.70 0.25],'String',sprintf('Select the file for: %s',v001.name),...
'Callback',@text2im__select_png);v005=struct('f',v004);guidata(v004,v005),uiwait(v004),v005=...
guidata(v004);close(v004),v000=imread(fullfile(v005.path,v005.file));end
function text2im__select_png(obj,e),v000=guidata(obj);[v000.file,v000.path]=...
uigetfile('text2im_glyphs_*.png');guidata(obj,v000);uiresume(v000.f);end
function v000=tmpname(v001,v002),if nargin<1,v001='';end,if ~isempty(v001),v001=[v001 '_'];end,...
if nargin<2,v002='';else,if ~strcmp(v002(1),'.'),v002=['.' v002];end,end,v000=tempname;[v003,...
v004]=fileparts(v000);v000=fullfile(v003,[v001 v004 v002]);end
function v000=unicode_to_char(v001,v002),persistent v003,if isempty(v003),v003 = ...
exist('OCTAVE_VERSION', 'builtin') ~= 0;end,if nargin==1,v002=~v003;end,if v002,if ...
all(v001<65536),v000=uint16(v001);v000=reshape(v000,1,numel(v000));else,[v004,v005,v006]=...
unique(v001);v000=cell(1,numel(v001));for v007=1:numel(v004),v008=unicode_to_UTF16(v004(v007));
v008=uint16(v008);v000(v006==v007)={v008};end,v000=cell2mat(v000);end,if ~v003,v000=char(v000);
end,else,if all(v001<128),v000=char(v001);v000=reshape(v000,1,numel(v000));else,[v004,v005,...
v006]=unique(v001);v000=cell(1,numel(v001));for v007=1:numel(v004),v008=...
unicode_to_UTF8(v004(v007));v008=uint8(v008);v000(v006==v007)={v008};end,v000=cell2mat(v000);
v000=char(v000);end,end,end
function v000=unicode_to_UTF16(v001),if v001<65536,v000=v001;return,end,v002=double(v001)-65536;
v002=dec2bin(v002,20);v000=bin2dec(['110110' v002(1:10);'110111' v002(11:20)]).';end
function v000=unicode_to_UTF8(v001),if v001<128,v000=v001;return,end,persistent v002,if ...
isempty(v002),v002=struct;v002.limits.lower=hex2dec({'0000','0080','0800', '10000'});
v002.limits.upper=hex2dec({'007F','07FF','FFFF','10FFFF'});v002.scheme{2}='110xxxxx10xxxxxx';
v002.scheme{2}=reshape(v002.scheme{2}.',8,2);v002.scheme{3}='1110xxxx10xxxxxx10xxxxxx';
v002.scheme{3}=reshape(v002.scheme{3}.',8,3);v002.scheme{4}='11110xxx10xxxxxx10xxxxxx10xxxxxx';
v002.scheme{4}=reshape(v002.scheme{4}.',8,4);for v003=2:4,v002.scheme_pos{v003}=...
find(v002.scheme{v003}=='x');v002.bits(v003)=numel(v002.scheme_pos{v003});end,end,v004=...
find(v002.limits.lower<=v001 & v001<=v002.limits.upper);v000=v002.scheme{v004};v005=...
v002.scheme_pos{v004};v003=dec2bin(v001,v002.bits(v004));v000(v005)=v003;v000=bin2dec(v000.').';
end
function [v000,v001,v002]=UTF8_to_unicode_internal(v000,v003),v001='success';v002=...
struct('identifier','HJW:UTF8_to_unicode:notUTF8','message','Input is not UTF-8.');persistent ...
v004,if isempty(v004),v004 = exist('OCTAVE_VERSION', 'builtin') ~= 0;end,if any(v000>255),v001=...
'error';if v003,return,end,elseif all(v000<128),return,end,for v005=4:-1:2,v006=...
bin2dec([repmat('1',1,v005) repmat('0',1,8-v005)]);v007=v000>=v006 & v000<256;if any(v007),v007=...
find(v007);v007=v007(:).';if numel(v000)<(max(v007)+v005-1),v001='error';if v003,return,end,...
v007( (v007+v005-1)>numel(v000) )=[];end,if ~isempty(v007),v008=bsxfun_plus(v007 , ...
(0:(v005-1)).' );v008=v008.';v007=v000(v008);end,else,v007=[];end,v009=[repmat('1',1,v005-1) ...
repmat('10',1,v005)];v010=unique([1:(v005+1) 1:8:(8*v005) 2:8:(8*v005)]);if numel(v007)>0,v007=...
unique(v007,'rows');v011=mat2cell(v007,ones(size(v007,1),1),v005);for v012=1:numel(v011),v013=...
dec2bin(double(v011{v012}))';if ~strcmp(v009,v013(v010)),v001='error';if v003,return,end,...
continue,end,v013(v010)='';if ~v004,v014=uint32(bin2dec(v013 ));else,v014=...
uint32(bin2dec(v013.'));end,v000=PatternReplace(v000,v011{v012},v014);end,end,end,end
function v000=UTF16_to_unicode(v001),persistent v002,if isempty(v002),v002 = ...
exist('OCTAVE_VERSION', 'builtin') ~= 0;end,v001=uint32(v001);v003= v001>55295 & v001<57344;if ...
~any(v003),v000=v001;return,end,v004= find( v001>=55296 & v001<=56319 );v005= find( v001>=56320 ...
& v001<=57343 );try v006=v005-v004;if any(v006~=1),error('trigger error'),end,catch,...
error('input is not valid UTF-16 encoded'),end,v007='110110110111';v008=[1:6 17:22];v003=...
v001([v004.' v005.']);v003=unique(v003,'rows');v009=mat2cell(v003,ones(size(v003,1),1),2);v000=...
v001;for v010=1:numel(v009),v011=dec2bin(double(v009{v010}))';if ~strcmp(v007,v011(v008)),...
error('input is not valid UTF-16 encoded'),end,v011(v008)='';if ~v002,v012=uint32(bin2dec(v011 ...
));else,v012=uint32(bin2dec(v011.'));end,v012=v012+65536;v000=PatternReplace(v000,v009{v010},...
v012);end,end
function [v000,v001,v002]=UTF8_to_unicode(v003,v004),if nargin<2,v004=[];end,v005= nargout==1 ;
v003=uint32(v003);[v002,v006,v007]=UTF8_to_unicode_internal(v003,v005);if strcmp(v006,...
'success'),v001=true;v000=v002;elseif strcmp(v006,'error'),v001=false;if v005,error_(v004,v007),...
end,v000=v003;end,end
function v000=ComputeNonCryptHash_shuffle_uint16_inv(v000),v001=65537;v002=1919;v000=...
uint16(mod(double(v000) * v002,v001));end
function v000=ComputeNonCryptHash_uint16_to_logical(v000),persistent v001,if isempty(v001),v001=...
dec2bin(0:(-1+2^16))=='1';v001=v001.';end,v000=double(v000)+1;v000=v001(:,v000);end
function v000=ComputeNonCryptHash_DefaultsByVersion(v000),if ~isfield(v000,...
're_encode_char_on_Octave'),v000.re_encode_char=v000.Version>=2;end,if ~isfield(v000,...
'string_to_cellstr'),v000.string_to_cellstr=v000.Version>=2;if ~isfield(v000,...
'cast_int64_double'),v000.cast_int64_double=v000.Version==1;end,end,end
function [v000,v001]=validate_print_to__options(v002,v001),if nargin<2,v001=struct;end,if ...
~isfield(v002,'print_to_con'),v002.print_to_con=[];end,if ~isfield(v002,'print_to_fid'),...
v002.print_to_fid=[];end,if ~isfield(v002,'print_to_obj'),v002.print_to_obj=[];end,if ...
~isfield(v002,'print_to_fcn'),v002.print_to_fcn=[];end,v003=true;v000=struct;v004=...
v002.print_to_fid;if isempty(v004),v000.boolean.fid=false;else,v003=false;v000.boolean.fid=true;
v000.fid=v004;for v005=1:numel(v004),try v006=ftell(v004(v005));catch,v006=-1;end,if ...
v004(v005)~=1 && v006==-1,v001.message=['Invalid print_to_fid parameter:',char(10),...
'should be a valid file identifier or 1.'];v000=[];return,end,end,end,v004=v002.print_to_obj;if ...
isempty(v004),v000.boolean.obj=false;else,v003=false;v000.boolean.obj=true;v000.obj=v004;for ...
v005=1:numel(v004),try v007=get(v004(v005),'String' );set( v004(v005),'String','' );set( ...
v004(v005),'String',v007);catch,v001.message=['Invalid print_to_obj parameter:',char(10),...
'should be a handle to an object with a writeable String property.'];v000=[];return,end,end,end,...
v004=v002.print_to_fcn;if isempty(v004),v000.boolean.fcn=false;else,v003=false;try for v005=...
1:numel(v004),if ~ismember(class(v004(v005).h),{'function_handle','inline'}) || ...
numel(v004(v005).h)~=1,error('trigger error'),end,end,catch,v001.message=...
['Invalid print_to_fcn parameter:',char(10),...
'should be a struct with the h field containing a function handle,',char(10),...
'anonymous function or inline function.'];v000=[];return,end,end,v004=v002.print_to_con;if ...
isempty(v004),v000.boolean.con=v003;else,[v008,v000.boolean.con]=test_if_scalar_logical(v004);
if ~v008,v001.message=['Invalid print_to_con parameter:',char(10),...
'should be a scalar logical.'];v000=[];return,end,end,end
function varargout=var2str(varargin),v000= nargin~=max(1,nargout) ;if ~v000,varargout=...
cell(nargin,1);for v001=1:nargin,try varargout{v001}=inputname(v001);catch,varargout{v001}='';
end,if isempty(varargout{v001}),v000=true;break,end,end,end,if v000,...
error('Invalid input and/or output.'),end,end
function warning_(v001,varargin),persistent v000,if isempty(v000),v000=func2str(@warning_);end,...
if isempty(v001),v001=struct;end,v001=parse_warning_error_redirect_options(v001);[v002,v003,...
v004,v005]=parse_warning_error_redirect_inputs(varargin{:});v006=struct('identifier',v002,...
'message',v003,'stack',v004);if v001.boolean.con,if ~isempty(v002),warning(v002,'%s',v003),else,...
warning(v003), end,else,if ~isempty(v002),lastwarn(v003,v002); else,lastwarn(v003),end,end,if ...
v001.boolean.obj,v007=v003;while v007(end)==10,v007(end)=[];end,if any(v007==10),v007=...
char2cellstr(['Warning: ' v007]);else,v007=['Warning: ' v007];end,set(v001.obj,'String',v007),...
for v008=v001.obj(:).',try set(v008,'String',v007);catch,end,end,end,if v001.boolean.fid || ...
v001.boolean.fcn,v009=2;[v005,v004]=get_trace(v009);end,if v001.boolean.fid,for v010=...
v001.fid(:).',try fprintf(v010,'Warning: %s\n%s',v003,v005);catch,end,end,end,if ...
v001.boolean.fcn,if ismember(v000,{v004.name}),error('prevent recursion'),end,for v011=...
v001.fcn(:).',if isfield(v011,'data'),try feval(v011.h,'warning',v006,v011.data);catch,end,else,...
try feval(v011.h,'warning',v006);catch,end,end,end,end,end