from
Example of loading C DLL and performance comparison
by Vinesh Bhunjun
The example shows how to load a C DLL and also compares it with Matlab files
|
| acc=myconvm2(hxstr)
|
function acc=myconvm2(hxstr)
% ACC = MYCONVM1(HXSTR) outputs the numeric representation of a Hex string number
% This is a vectorized Matlab version, i.e. it's faster
% Input:
% HXSTR: a string of the form '0x123', '0X123' or '123',
% default value is '0x123'
% Output:
% ACC: the numeric representation of the number
if(nargin<1)
hxstr='0x123';
end
if(hxstr(1)=='0' && lower(hxstr(2))=='x' )
ix=3;
end
vec=16.^(length(hxstr)-ix : -1 :0);
dig=find((hxstr>='0' & hxstr<='9'));
ndig=find((hxstr<'0' | hxstr>'9'));
a(dig)=double(hxstr(dig))-double('0');
a(ndig)=double(lower(hxstr(ndig)))-double('a')+10;
acc=sum(a(ix:end).*vec);
|
|
Contact us at files@mathworks.com