MATLAB Answers

minify Matlab code (minimize number of characters)

24 views (last 30 days)
Rik on 9 Oct 2020
Commented: Rik on 18 Nov 2020 at 9:43
I would like to find a way that reduces the footprint of a function as much as possible. The actual functionality should not change (although stripping the message part of errors and warnings would be fine).
My intended purpose is to be able to add a function as a dependency, without having to fill pages and pages with (in such a case) irrelevant details. Only the entry function name should be the same, the rest is irrelevant. The resulting function should behave the exact same and still be in plain text.
Is there a good place to start? Is it possible to hook into the Matlab parser somehow to reliably determine which characters are comments (maybe by borrowing some of the work that happened for Octave)? I attempted to search on Google (and the FEX) to see if something was already available, but search queries like 'minimize Matlab code' obviously turn up a lot of unrelated results. I did find Matmini on Github, but that is poorly documented, 7 years old and in Python. I did get it to run, but it doesn't work as intended (the published version doesn't have nargin and nargout as special tokens, doesn't seem to handle ... at all, replaces many functions with the compact strings, and messes up many (if not most) of the chars).
My current solution involves stripping all line comments (i.e. lines starting with % or . when ignoring leading spaces) and removing all empty lines. This reduces my readfile function from 651 lines to 416, but I would prefer an even more drastic reduction. Matmini chops it down to 262 (if I manually replace all ...\n), but then it no longer actually works.
for n=1:numel(txt)
idx=find(s~=' ',1,'first');
if ~isempty(idx) && any(s(idx)=='%.')
if all(s==' '),txt{n}='';end
%What I tried with Matmini:
alphabet=string(['a':'z' 'A':'Z']);
Another use case would be in places like the attached document. In such cases I want to be able to add extra functions at the end that will generate data to run the performance test. It isn't a big problem to have a large code block there, but I would prefer to have the option if I feel like it. (document like this one should show up in the examples tab in the FEX once they fix the 'preview not available' bug for entries linked to Github)


per isakson
per isakson on 12 Oct 2020
This (attached) is how I use Acklam's code. (txt2str() is included in m2uml). It doesn't handle comments after ellipsis.
Rik on 12 Oct 2020
Meanwhile I was adapting that very same function. Attached is my result. It gobbles empty lines and correctly handles (and merges) comments after ellipses.
Edit: updated version that also should work for strings.
mainregex = [ ...
'( ' ... % Grouping parenthesis (content goes to $1).
' ( ^ | \n ) ' ... % Beginning of string or beginning of line.
' ( ' ... % Non-capturing grouping parenthesis.
' ' ...
'' ... % Match anything that is neither a comment nor a char array nor a string...
' ( ' ... % Non-capturing grouping parenthesis.
' [\]\)}\w.] ' ... % Either a character followed by
' ''+ ' ... % one or more transpose operators
' | ' ... % or else
' [^''"%](?!\.\.) ' ... % any character except a single/double quote (which
' ' ... % starts a char or string), or a percent (which starts
' ' ... % a comment), as long as it isn't the first dot of a ...
' ' ... % (requiring gobbling a newline). (note: this will generally
' ' ... % select 1 char too much for ...)
' )+ ' ... % Match one or more times.
' ' ...
'' ... % ...or...
' | ' ...
' ' ...
'' ... % ...match a char array.
' ( ' ... % Non-capturing grouping parenthesis.
' '' ' ... % Opening single quote that starts the char.
' [^''\n]* ' ... % Zero or more characters that are neither single quotes
' ' ... % (special) nor newlines (illegal).
' ( ' ... % Non-capturing grouping parenthesis.
' '''' ' ... % An embedded (literal) single quote character.
' [^''\n]* ' ... % Again, zero or more characters that are neither single quotes
' ' ... % nor newlines.
' )* ' ... % Match zero or more times.
' '' ' ... % Closing single quote that ends the char.
' ) ' ...
' ' ...
'' ... % ...or...
' | ' ...
' ' ...
'' ... % ...match a string.
' ( ' ...
' " ' ... % Opening double quote that starts the string.
' [^"\n]* ' ... % Zero or more characters that are neither double quotes
' ' ... % (special) nor newlines (illegal).
' ( ' ... % Non-capturing grouping parenthesis.
' "" ' ... % An embedded (literal) double quote character.
' [^"\n]* ' ... % Again, zero or more characters that are neither double quotes
' ' ... % nor newlines.
' )* ' ... % Match zero or more times.
' " ' ... % Closing double quote that ends the string.
' ) ' ...
' ' ...
' )* ' ... % Match zero or more times.
') ' ...
'[^\n]* ' ... % What remains must be a comment.
Rik on 18 Nov 2020 at 9:43
While writing a tester, I noticed that the regex above doesn't correctly handle transposing a scalar string (althought I am not sure why you would transpose a scalar). So it fails for the line of code below.
% ^ transpose
% ^ start of comment
Putting any character between the double and single quote fixes this issue (''"" fails as well, but that doesn't matter, as it is not valid Matlab syntax). My current test cases are posted below. This is the only failing case, but I'm not sure it is important enough to spend a lot of time fixing it.
%just a few examples of hard to parse syntaxes

Sign in to comment.

Answers (2)

J. Alex Lee
J. Alex Lee on 12 Oct 2020
Partial answer to implement Rik's original stripping of blank lines and full comment lines, and also attempt to squeeze the line continuations (though may not be robust to detect ellipses followed by comments; slightly modified regex to detect comments following ellipses, not sure if it is better or worse)
txt = readfile("readfile.m"); % use Rik's own readfile to return as cell array of char arrays
% simple stripping of full comment lines and empty lines
txt = regexprep(txt,'^\s*\%.*$','');
txt = regexprep(txt,'^\s*$','');
txt(cellfun(@isempty,txt)) = [];
txt = regexprep(txt,'(?<=\.\.\.)\s*\%*.*$','');
str = join(string(txt)+newline,"");
str = regexprep(str,'\.\.\.\s*\n\s*',' ');
txt = split(str,newline);
Does not address the more interesting part of the problem, to detect variable names and replace with shorter variable names.


Sign in to comment.

Rik on 14 Oct 2020
Edited: Rik on 12 Nov 2020 at 14:44
It took some time, but here is my solution.
  1. Strip all comments and line continuations.
  2. Separate the code and the embeded chars/strings.
  3. Parse the code to select only the places where a new variable may be created in the workspace.
  4. Use that (and the list of local functions) to create a dictionary of variable and function names.
  5. Remove the entry function from that dictionary and replace every occurence of a variable or local function with a shorter/pseudonimized one.
  6. Optional: replace all double spaces in code with single space.
  7. Put the code and chars/strings back together.
  8. Optional: merge and split lines so the result is shorter that a fixed length.
Any eval that relies on variable or function names is doomed to fail, but I think that is a feature, not a bug. The current version of the code also ignores the argument block, so if a function is using that, there will very likely be issues.
I will probably post this function to the FEX later on, but here it is already. The result below is for the readfile function (with a max line length of 150 characters). I think this update is nearing completion. I'm now going to write a few tests so I can confirm compatibility with Octave and old Matlab releases, but on R2020b it already works like a charm. It reduces the total function length by about 80% (in this specific case 86%, from 987 lines to 138).
% readfile (version 3.0.0) was minified to make it more compact.
% For the normal version see
function v001=readfile(v002,varargin)
if nargin<1;error('HJW:readfile:nargin',...
'Incorrect number of input argument.');end;if ~(nargout==0 || nargout==1);error('HJW:WBM:nargout','Incorrect number of output argument.');
end;[v003,v004,v005]=f10(v002,varargin{:});if ~v003;rethrow(v005);else;[v006,v007,v008]=deal(v004.legacy,v004.UseURLread,...
v004.err_on_ANSI);v009=struct('con',v004.print_2_con,'fid',v004.print_2_fid,'obj',v004.print_2_obj);end;if isa(v002,'string'),v002=char(v002);
end;if numel(v002)>=8 && ( strcmp(v002(1:7),'http://') || strcmp(v002(1:8),'https://') );if ~v006.allows_https && strcmp(v002(1:8),...
'https://');f18(v009,'HJW:readfile:httpsNotSupported',['This implementation of urlread probably doesn''t allow https requests.',...
char(10),'The next lines of code will probably result in an error.']);end;v010=f09(v002,v007,v009);if isa(v010,'cell');v001=v010;
else;v011=true;v010=f03(v010,v011);try [v012,v013,v014]=f16(v010);catch;v005=lasterror;if strcmp(v005.identifier,'HJW:UTF8_to_unicode:notUTF8');
v013=false;else;f04(v009,v005);end;end;if v013;v010=f13(v014);end;v001=f02(v010);end;else;v001=f08(v002,v009,v008);end;end
function v015=f01(v016,v017)
try v015=v016+v017;catch;try v015=bsxfun(@plus,v016,...
v017);catch;v019=size(v016); v018=size(v017);v016=repmat(v016,max(1,v018./v019)); v017=repmat(v017,max(1,v019./v018));v015=v016+v017;end;end;end
function v020=f02(v010)
v021=[0 find(v010==10) numel(v010)+1];
v020=cell(numel(v021)-1,1);for v022=1:numel(v020);v023=(v021(v022 )+1);v024=(v021(v022+1)-1);v020{v022}=v010(v023:v024);end;end
function v010=f03(v010,v025)
persistent v026 v027;if isempty(v026);v028=[338 140;
339 156;352 138;353 154;376 159;381 142;382 158;402 131;710 136;732 152;8211 150;8212 151;8216 145;8217 146;8218 130;8220 147;8221 148;
8222 132;8224 134;8225 135;8226 149;8230 133;8240 137;8249 139;8250 155;8364 128;8482 153];v026=v028(:,2);v027=v028(:,1);end;if nargin>1 && v025;
v030=v027;v029=v026;else;v030=v026;v029=v027;end;v010=uint32(v010);for v031=1:numel(v030);v010=f07(v010,v030(v031),v029(v031));end;end
function f04(v032,varargin)
if isempty(v032),v032=struct;end;if ~isfield(v032,'fid'),v032.fid.boolean=false;end;if ~isfield(v032,'obj'),v032.obj.boolean=false;
end;if nargin==2;if isa(varargin{1},'struct') || isa(varargin{1},'MException');v005=varargin{1};try v033=v005.stack;v034=f05(0,v033);catch;[v034,...
v033]=f05(2);end;v035=v005.identifier;v036=v005.message;v037='Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback(';
if isa(v005,'struct') && numel(v036)>numel(v037) && strcmp(v037,v036(1:numel(v037)));v036(1:find(v036==10,...
1))='';end;else;[v034,v033]=f05(2);[v035,v036]=deal('',varargin{1});end;else;[v034,v033]=f05(2);if ~isempty(strfind(varargin{1},...
'%'));v035='';v038=varargin(2:end);v036=sprintf(varargin{1},v038{:});else;v035=varargin{1};v036=varargin{2};if nargin>3;
v038=varargin(3:end);v036=sprintf(v036,v038{:});end;end;end;v005=struct('identifier',v035,'message',v036,'stack',v033);if v032.obj.boolean;
v039=v036;while v039(end)==10,v039(end)='';end;if any(v039==10);v039=regexp_outkeys(['Error: ' v039],char(10),'split');else;v039=['Error: ' v039];
end;set(v032.obj.obj,'String',v039);end;if v032.fid.boolean;fprintf(v032.fid.fid,'Error: %s\n%s',v036,v034);end;rethrow(v005);end
function [v010,v033]=f05(v040,v033)
if nargin==0,v040=1;
end;if nargin<2, v033=dbstack;end;v033(1:v040)=[];if ~isfield(v033,'file');for v022=1:numel(v033);v041=v033(v022).name;if strcmp(v041(end),')');
v042=strfind(v041,'(');v043=v041( (v042(end)+1):(end-1) );v044=v041(1:(v042(end)-2));else;v044=v041;[v045,v043]=fileparts(v041);
end;[v045,v033(v022).file]=fileparts(v044);v033(v022).name=v043;end;end;persistent v046,if isempty(v046),v046=exist('OCTAVE_VERSION',...
'builtin');end;if v046;for v022=1:numel(v033);[v045,v033(v022).file]=fileparts(v033(v022).file);end;end;v047=v033;v048='>';
v010=cell(1,numel(v047)-1);for v022=1:numel(v047);[v049,v047(v022).file,v050]=fileparts(v047(v022).file);if v022==numel(v047),v047(v022).file='';
end;if strcmp(v047(v022).file,v047(v022).name),v047(v022).file='';end;if ~isempty(v047(v022).file),v047(v022).file=[v047(v022).file '>'];
end;v010{v022}=sprintf('%c In %s%s (line %d)\n',v048,v047(v022).file,v047(v022).name,v047(v022).line);v048=' ';end;v010=horzcat(v010{:});end
function v051=f06(v052,v053,v054,v055,v056)
persistent v057 v058 v059;if isempty(v057);v059=exist('OCTAVE_VERSION', 'builtin');v057=version;
v012=strfind(v057,'.');if numel(v012)~=1,v057(v012(2):end)='';v012=v012(1);end;v057=[str2double(v057(1:(v012-1))) str2double(v057((v012+1):end))];
v057=v057(1)+v057(2)/100;v057=round(100*v057);v058={ '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};end;if v059;if nargin==2;
warning('HJW:ifversion:NoOctaveTest',['No version test for Octave was provided.',char(10),'This function might return an unexpected outcome.']);
v060=ismember(v058(:,1),v053);if sum(v060)~=1;warning('HJW:ifversion:NotInDict','The requested version is not in the hard-coded list.');
v051=NaN;return;else;v061=v058{v060,2};end;elseif nargin==4;[v052,v061]=deal(v054,v055);v061=0.1*v061+0.9*fix(v061);
v061=round(100*v061);else;[v052,v061]=deal(v055,v056);v061=0.1*v061+0.9*fix(v061);v061=round(100*v061);end;else;if isnumeric(v053);
v061=0.1*v053+0.9*fix(v053);v061=round(100*v061);else;v060=ismember(v058(:,1),v053);if sum(v060)~=1;warning('HJW:ifversion:NotInDict',...
'The requested version is not in the hard-coded list.');v051=NaN;return;else;v061=v058{v060,2};end;end;end;switch v052;case '==',...
v051= v057 == v061;case '<' , v051= v057 < v061;case '<=', v051= v057 <= v061;case '>' , v051= v057 > v061;case '>=', v051= v057 >= v061;end;end
function v015=f07(v062,v063,v064)
v015=v062(:)';if numel(v063)==0;v060=false(size(v062));elseif numel(v064)>numel(v063);error('not implemented (padding required)');else;
v060=true(size(v062));for v022=1:numel(v063);v065=find(v062==v063(v022));v065=v065-v022+1;v065(v065<1)=[];v066=false(size(v060));v066(v065)=true;
v060= v060 & v066;if ~any(v060),break,end;end;end;v065=find(v060);if ~isempty(v065);for v022=1:numel(v064);v015(v065+v022-1)=v064(v022);
end;if numel(v064)==0,v022=0;end;if numel(v063)>v022;v065=v065(:);v067=(v022+1):numel(v063);v068=f01(v065,v067-1);v015(v068(:))=[];end;end;end
function v010=f08(v002,v009,v008)
if nargin==1,v009=struct;v008=false;end;persistent v069,if isempty(v069),v069 = exist('OCTAVE_VERSION',...
'builtin') ~= 0;end;persistent v070;if isempty(v070);if v069,v071='Octave';else,v071='Matlab';end;v070=struct('identifier',...
'HJW:readfile:ReadFail','message',sprintf('%s could not read the file %s.\nThe file doesn''t exist or is not readable.',v071,...
v002));end;v072=fopen(v002,'rb');if v072<0,f04(v009,v070),end;v001=fread(v072,'uint8');fclose(v072);v001=v001.';try v013=true;
v014=f16(v001);catch;v005=lasterror;if strcmp(v005.identifier,'HJW:UTF8_to_unicode:notUTF8');v013=false;if v008;f04(v009,'HJW:readfile:notUTF8',...
'The provided file "%s" is not a correctly encoded UTF-8 file.',v002);end;else;f04(v009,v005);end;end;if v069;if v013;v010=v014;
else;try v010=fileread(v002);catch,f04(v009,v070),end;v010=f03(v010);end;else;if ispc;if v013;v010=v014;else;if f06('<',7);try v010=fileread(v002);
catch,f04(v009,v070),end;v010=f03(v010);else;try v010=fileread(v002);catch,f04(v009,v070),end;end;end;else;if v013;v010=v014;
else;v010=f03(v001);end;end;end;v010(v010==13)=[];if numel(v010)>=1 && double(v010(1))==65279,v010(1)=[];end;v010=f13(v010);v010=f02(v010);end
function v010=f09(v073,v007,v074)
try v075=false;v076=f12('readfile_from_URL_tmp_','.txt');try if v007,...
v076=urlwrite(v073,v076);else,v076=websave(v076,v073);end;v010=f08(v076);catch;v075=true;end;try if exist(v076,'file'),delete(v076);end,catch,end;
if v075,error('revert to urlread'),end;catch;try if v007,v010=urlread(v073);else,v010=webread(v073);end;catch;f04(v074,lasterror);end;end;end
function [v003,v032,v005]=f10(v002,varargin)
v005=struct('identifier','','message','');if ~( isa(v002,'char') || isa(v002,'string') ) ||( isa(v002,'string') && numel(v002)~=1 ) ||( isa(v002,...
'char') && numel(v002)==0 );v005.identifier='HJW:readfile:IncorrectInput';v005.message='The file name must be a non-empty char or a scalar string.';
return;end;persistent v077;if isempty(v077);v006.split = f06('<','R2007b',...
'Octave','<',4);v006.allows_https=f06('>',0,'Octave','<',0);v077.legacy=v006;v077.UseURLread=isempty(which('webread')) || isempty(which('websave'));
end;if nargin==1;v032=v077;v003=true;return;end;v078=nargin==2 && isa(varargin{1},'struct');v079=mod(nargin,2)==1 &&all(cellfun('isclass',...
varargin(1:2:end),'char'));if ~( v078 || v079 );v005.message=['The second input (options) is expected to be either a struct, ',...
'or consist of Name,Value pairs.'];v005.identifier='HJW:readfile:incorrect_input_options';
return;end;if v079;for v022=1:2:numel(varargin);try v032.(varargin{v022})=varargin{v022+1};catch;v005.message='Parsing of Name,Value pairs failed.';
v005.identifier='HJW:readfile:incorrect_input_NameValue';return;end;end;else;v032=varargin{1};end;v076=fieldnames(v032);for v065=1:numel(v076);
v080=v076{v065};v081=v032.(v080);v005.identifier=['HJW:readfile:incorrect_input_opt_' lower(v080)];switch v080;case 'UseURLread';
[v082,v081]=f11(v081);if ~v082;v005.message='UseURLread should be either true or false';return;end;v032.UseURLread=v081 || v077.UseURLread;
case 'err_on_ANSI';[v082,v081]=f11(v081);if ~v082;v005.message='err_on_ANSI should be either true or false';return;end;
v032.show_UTF_err=v081;case 'print_to_fid';if isempty(v081);v032.print_2_fid.boolean=false;else;v032.print_2_fid.boolean=true;try v083=ftell(v081);
catch,v083=-1;end;if v081~=1 && v083==-1;v005.message=['Invalid print_to_fid parameter: ','should be a valid file identifier or 1'];
return;end;v032.print_2_fid.fid=v081;end;case 'print_to_obj';if isempty(v081);v032.print_2_obj.boolean=false;
else;v032.print_2_obj.boolean=true;try v084=get(v081,'String');set(v081,'String','');set(v081,'String',v084);v032.print_2_obj.obj=v081;
catch;v005.message=['Invalid print_to_obj parameter: ','should be a handle to an object with a writeable String property'];
return;end;end;case 'print_to_con';[v082,v032.print_2_con]=f11(v081);if ~v082;v005.message='print_to_con should be either true or false';
return;end;end;end;if ~isfield(v032,'print_2_con') &&( isfield(v032,'print_2_fid') || isfield(v032,'print_2_obj') );v032.print_2_con=false;
end;v076=fieldnames(v077);for v065=1:numel(v076);if ~isfield(v032,v076(v065));v032.(v076{v065})=v077.(v076{v065});end;end;v003=true;v005=[];end
function [v085,v086]=f11(v086)
persistent v087;if isempty(v087);v087={true,false;1,0;
'on','off'};try v087(end+1,:)=eval('{"on","off"}');catch;end;end;v085=true;try for v022=1:size(v087,1);for v031=1:2;if isequal(v086,v087{v022,...
v031});v086=v087{1,v031};return;end;end;end;if isa(v086,'matlab.lang.OnOffSwitchState');v086=logical(v086);return;end;catch;end;v085=false;end
function v010=f12(v088,v089)
if nargin<1,v088='';end;if ~isempty(v088),v088=[v088 '_'];end;if nargin<2,...
v089='';else,if ~strcmp(v089(1),'.'),v089=['.' v089];end,end;v010=tempname;[v090,v091]=fileparts(v010);v010=fullfile(v090,[v088 v091 v089]);end
function v010=f13(v092,v093)
persistent v069,if isempty(v069),v069 = exist('OCTAVE_VERSION', 'builtin') ~= 0;end;if nargin==1;v093=~v069;
end;if v093;if all(v092<65536);v010=uint16(v092);v010=reshape(v010,1,numel(v010));else;[v094,v045,v095]=unique(v092);v010=cell(1,numel(v092));
for v022=1:numel(v094);v096=f14(v094(v022));v096=uint16(v096);v010(v095==v022)={v096};end;v010=cell2mat(v010);end;if ~v069;v010=char(v010);
end;else;if all(v092<128);v010=char(v092);v010=reshape(v010,1,numel(v010));else;[v094,v045,v095]=unique(v092);v010=cell(1,numel(v092));
for v022=1:numel(v094);v096=f15(v094(v022));v096=uint8(v096);v010(v095==v022)={v096};end;v010=cell2mat(v010);v010=char(v010);end;end;end
function v010=f14(v092)
if v092<65536;v010=v092;return;end;v097=double(v092)-65536;v097=dec2bin(v097,20);v010=bin2dec(['110110' v097(1:10);'110111' v097(11:20)]).';end
function v010=f15(v092)
if v092<128;v010=v092;return;end;persistent v098;if isempty(v098);v098=struct;v098.limits.lower=hex2dec({'0000','0080','0800', '10000'});
v098.scheme{4}=reshape(v098.scheme{4}.',8,4);for v099=2:4;v098.scheme_pos{v099}=find(v098.scheme{v099}=='x');
v098.bits(v099)=numel(v098.scheme_pos{v099});end;end;v100=find(v098.limits.lower<v092 & v092<v098.limits.upper);
function [v092,v013,v102]=f16(v103,v074)
if nargin<2,v074=[];end;v104= nargout==1 ;v103=uint32(v103);[v102,v105,v005]=f17(v103,...
v104);if strcmp(v105,'success');v013=true;v092=v102;elseif strcmp(v105,'error');v013=false;if v104;f04(v074,v005);end;v092=v103;end;end
function [v103,v105,v005]=f17(v103,v104)
'Input is not UTF-8.');persistent v069,if isempty(v069),v069 = exist('OCTAVE_VERSION', 'builtin') ~= 0;end;if any(v103>255);v105='error';if v104,...
return,end;elseif all(v103<128);return;end;for v100=4:-1:2;v086=bin2dec([repmat('1',1,v100) repmat('0',1,8-v100)]);v106=v103>=v086 & v103<256;
if any(v106);v106=find(v106);v106=v106(:).';if numel(v103)<(max(v106)+v100-1);v105='error';if v104,return,end;v106( (v106+v100-1)>numel(v103) )=[];
end;if ~isempty(v106);v068=f01(v106 , (0:(v100-1)).' );v068=v068.';v106=v103(v068);end;else;v106=[];end;v107=[repmat('1',1,...
v100-1) repmat('10',1,v100)];v108=unique([1:(v100+1) 1:8:(8*v100) 2:8:(8*v100)]);if numel(v106)>0;v106=unique(v106,'rows');v109=mat2cell(v106,...
ones(size(v106,1),1),v100);for v022=1:numel(v109);v110=dec2bin(double(v109{v022}))';if ~strcmp(v107,v110(v108));v105='error';if v104,return,end;
continue;end;v110(v108)='';if ~v069;v111=uint32(bin2dec(v110 ));else;v111=uint32(bin2dec(v110.'));end;v103=f07(v103,v109{v022},v111);end;end;end;end
function f18(v032,varargin)
if isempty(v032),v032=struct;end;
if ~isfield(v032,'con'),v032.con=false;end;if ~isfield(v032,'fid'),v032.fid.boolean=false;end;if ~isfield(v032,'obj'),v032.obj.boolean=false;end;
if nargin==2 || ~isempty(strfind(varargin{1},'%'));[v035,v036]=deal('',varargin{1});if nargin>3;v038=varargin(2:end);v036=sprintf(v036,v038{:});end;
else;[v035,v036]=deal(varargin{1},varargin{2});if nargin>3;v038=varargin(3:end);v036=sprintf(v036,v038{:});end;end;if v032.con;if ~isempty(v035);
warning(v035,'%s',v036);else;warning(v036);end;else;if ~isempty(v035);lastwarn(v036,v035);else;lastwarn(v036);end;end;if v032.obj.boolean;v039=v036;
while v039(end)==10,v039(end)=[];end;if any(v039==10);v039=regexp_outkeys(['Warning: ' v039],char(10),'split');else;v039=['Warning: ' v039];
end;set(v032.obj.obj,'String',v039);end;if v032.fid.boolean;v040=2;v034=f05(v040);fprintf(v032.fid.fid,'Warning: %s\n%s',v036,v034);end;end


Sign in to comment.




Community Treasure Hunt

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

Start Hunting!

Translated by