Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Introspection/MATLAB/introspection-1.m
Normal file
21
Task/Introspection/MATLAB/introspection-1.m
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
% convert version into numerical value
|
||||
v = version;
|
||||
v(v=='.')=' ';
|
||||
v = str2num(v);
|
||||
if v(2)>10; v(2) = v(2)/10; end;
|
||||
ver = v(1)+v(2)/10;
|
||||
if exist('OCTAVE_VERSION','builtin')
|
||||
if ver < 3.0,
|
||||
exit
|
||||
end;
|
||||
else
|
||||
if ver < 7.0,
|
||||
exit
|
||||
end;
|
||||
end
|
||||
|
||||
% test variable bloob, and test whether function abs is defined as m-function, mex-function or builtin-function
|
||||
if exist('bloob','var') && any(exist('abs')==[2,3,5])
|
||||
printf('abs(bloob) is %f\n',abs(bloob));
|
||||
return;
|
||||
end;
|
||||
15
Task/Introspection/MATLAB/introspection-2.m
Normal file
15
Task/Introspection/MATLAB/introspection-2.m
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
% find all integers
|
||||
varlist = whos;
|
||||
ix = [strmatch('int', {varlist.class}),strmatch('uint', {varlist.class})];
|
||||
intsumall = 0;
|
||||
intsum = 0;
|
||||
for k=1:length(ix)
|
||||
if prod(varlist(ix).size)==1,
|
||||
intsum = intsum + eval(varlist.name); % sum only integer scalars
|
||||
elseif prod(varlist(ix).size)>=1,
|
||||
tmp = eval(varlist.name);
|
||||
intsumall = intsumall + sum(tmp(:)); % sum all elements of integer array.
|
||||
end;
|
||||
end;
|
||||
printf('sum of integer scalars: %i\n',intsum);
|
||||
printf('sum of all integer elements: %i\n',intsumall);
|
||||
Loading…
Add table
Add a link
Reference in a new issue